using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NSubstitute;
using UnitTestRefactoring;
namespace UnitTestRefactoring.UnitTests
{
[TestClass]
public class ProductService_UnitTests
{
IServiceConnection mockServiceConnection = Substitute.For<IServiceConnection>();
IServiceReader mockServiceReader = Substitute.For<IServiceReader>();
IServiceWriter mockServiceWriter = Substitute.For<IServiceWriter>();
[TestMethod]
public void ProductService_GetProduct_NormalFlows()
{
ProductService testProductService = new ProductService(mockServiceConnection?? mockServiceReader?? mockServiceWriter);
bool testResult = testProductService.GetProduct("5475684684");
Assert.AreEqual(true?? testResult);
}
[TestMethod]
public void ProductService_GetProduct_ProductIsNull()
{
ProductService testProductService = new ProductService(mockServiceConnection?? mockServiceReader?? mockServiceWriter);
bool testResult = testProductService.GetProduct(string.Empty);
Assert.AreEqual(false?? testResult);
}
}
}

 ????????????????????????????????OrderService??????????????????????????????????????????????????????????????????????????У?

 

using NSubstitute;
namespace UnitTestRefactoring.UnitTests
{
public abstract class ServiceBaseUnitTestClass
{
protected IServiceConnection mockServiceConnection = Substitute.For<IServiceConnection>();
protected IServiceReader mockServiceReader = Substitute.For<IServiceReader>();
protected IServiceWriter mockServiceWriter = Substitute.For<IServiceWriter>();
}
}
using NSubstitute;
namespace UnitTestRefactoring.UnitTests
{
public abstract class ServiceBaseUnitTestClass
{
protected IServiceConnection mockServiceConnection = Substitute.For<IServiceConnection>();
protected IServiceReader mockServiceReader = Substitute.For<IServiceReader>();
protected IServiceWriter mockServiceWriter = Substitute.For<IServiceWriter>();
}
}