public void When_CustomerIsUsual_Get1000() { Mock <ICustomerRepository> mockCustomerRepository = new Mock <ICustomerRepository>(); mockCustomerRepository.Setup(c => c.Get(It.IsAny <int>())).Returns(new Customer { CustomerType = CustomerType.Usual }); GetDiscountValueService service = new GetDiscountValueService(mockCustomerRepository.Object); var result = service.Execute(2); Assert.Equal(1000, result); }
public void CheckStateManagement() { Mock <ICustomerRepository> mockCustomerRepository = new Mock <ICustomerRepository>(); mockCustomerRepository.SetupProperty(c => c.UsedCount); // نگهداری مقدار //mockCustomerRepository.SetupAllProperties(); // نگهداری تمام مقدار mockCustomerRepository.Setup(c => c.Get(It.IsAny <int>())).Returns(new Customer { CustomerType = CustomerType.Usual }); GetDiscountValueService service = new GetDiscountValueService(mockCustomerRepository.Object); var result = service.Execute(2); Assert.Equal(1000, result); }