public void ConstructorShould_CreateProductService() { // Arrange var EfRepositoryStub = new Mock <IEfRepository <Product> >(); var SaveContextStub = new Mock <ISaveContext>(); // Act var productServiceMock = new TelerikAcademy.FinalProject.Services.ProductsService(EfRepositoryStub.Object, SaveContextStub.Object); // Assert Assert.IsNotNull(productServiceMock); }
public void GetAll_Should_CallRepository_All() { // Arrange var EfRepositoryStub = new Mock <IEfRepository <Product> >(); var SaveContextStub = new Mock <ISaveContext>(); var productsServiceMock = new TelerikAcademy.FinalProject.Services.ProductsService(EfRepositoryStub.Object, SaveContextStub.Object); // Act productsServiceMock.GetAll(); // Assert EfRepositoryStub.Verify(x => x.All, Times.Once); }
public void GetById_ShouldReturnsNullWhenProductIdIsNull() { // Arrange var EfRepositoryStub = new Mock <IEfRepository <Product> >(); var SaveContextStub = new Mock <ISaveContext>(); var productService = new TelerikAcademy.FinalProject.Services.ProductsService(EfRepositoryStub.Object, SaveContextStub.Object); // Act Product productModel = productService.GetById(null); // Assert Assert.IsNull(productModel); }