??????????????Order??????????????GetOrders???÷??????????OrderId?????Order?????????????????????true?????????ó???????????false??????????????й??????????????????????????????????????????IServiceConnection???????????????????IServiceReader????????????????????IServiceWriter?????????????д????????????????????????



using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NSubstitute;
using UnitTestRefactoring;
namespace UnitTestRefactoring.UnitTests
{
[TestClass]
public class OrderService_UnitTests
{
[TestMethod]
public void OrderService_GetOrders_NormalFlows()
{
IServiceConnection mockServiceConnection = Substitute.For<IServiceConnection>();
IServiceReader mockServiceReader = Substitute.For<IServiceReader>();
IServiceWriter mockServiceWriter = Substitute.For<IServiceWriter>();
OrderService testOrderService = new OrderService(mockServiceConnection?? mockServiceReader?? mockServiceWriter);
bool testResult = testOrderService.GetOrders("10293884");
Assert.AreEqual(true?? testResult);
}
[TestMethod]
public void OrderService_GetOrders_OrderIdIsNull()
{
IServiceConnection mockServiceConnection = Substitute.For<IServiceConnection>();
IServiceReader mockServiceReader = Substitute.For<IServiceReader>();
IServiceWriter mockServiceWriter = Substitute.For<IServiceWriter>();
OrderService testOrderService = new OrderService(mockServiceConnection?? mockServiceReader?? mockServiceWriter);
bool testResult = testOrderService.GetOrders(string.Empty);
Assert.AreEqual(false?? testResult);
}
}
}
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NSubstitute;
using UnitTestRefactoring;
namespace UnitTestRefactoring.UnitTests
{
[TestClass]
public class OrderService_UnitTests
{
[TestMethod]
public void OrderService_GetOrders_NormalFlows()
{
IServiceConnection mockServiceConnection = Substitute.For<IServiceConnection>();
IServiceReader mockServiceReader = Substitute.For<IServiceReader>();
IServiceWriter mockServiceWriter = Substitute.For<IServiceWriter>();
OrderService testOrderService = new OrderService(mockServiceConnection?? mockServiceReader?? mockServiceWriter);
bool testResult = testOrderService.GetOrders("10293884");
Assert.AreEqual(true?? testResult);
}
[TestMethod]
public void OrderService_GetOrders_OrderIdIsNull()
{
IServiceConnection mockServiceConnection = Substitute.For<IServiceConnection>();
IServiceReader mockServiceReader = Substitute.For<IServiceReader>();
IServiceWriter mockServiceWriter = Substitute.For<IServiceWriter>();
OrderService testOrderService = new OrderService(mockServiceConnection?? mockServiceReader?? mockServiceWriter);
bool testResult = testOrderService.GetOrders(string.Empty);
Assert.AreEqual(false?? testResult);
}
}
}