예제 #1
0
        public void GetCompanyProductNotFound()
        {
            UoW.Setup(m => m.CompanyProducts.GetAll()).Returns(new List <CompanyProduct> {
            }.AsQueryable());

            // Act
            var result = Subject.GetCompanyProduct(TestData.ProductSkuCompanyCodeA, TestData.CompanyCodeA);

            // Assert
            Assert.Null(result);
        }
예제 #2
0
        public void GetSupplierNotFound()
        {
            UoW.Setup(m => m.Suppliers.GetAll()).Returns(new List <Supplier> {
            }.AsQueryable());

            // Act
            var result = Subject.GetSupplier(TestData.ExistingSupplierCode, TestData.CompanyCodeA);

            // Assert
            Assert.Null(result);
        }
예제 #3
0
        public void ValidateCompanyProductDoesNotExist()
        {
            UoW.Setup(m => m.CompanyProducts.GetAll()).Returns(new List <CompanyProduct> {
            }.AsQueryable());

            // Act
            var result = Subject.ValidateCompanyProductExist(TestData.ProductSkuCompanyCodeA, TestData.CompanyCodeA);

            // Assert
            Assert.Contains(typeof(ProductSkuNotFoundError),
                            result.Where(m => m.Field == "ProductSku").Select(e => e.GetType()).ToList());
        }
예제 #4
0
        public void ValidateSupplierDoesNotExist()
        {
            UoW.Setup(m => m.Suppliers.GetAll()).Returns(new List <Supplier> {
            }.AsQueryable());

            // Act
            var result = Subject.ValidateSupplierExist(TestData.ExistingSupplierCode, TestData.CompanyCodeA);

            // Assert
            Assert.Contains(typeof(SupplierCodeNotFoundError),
                            result.Where(m => m.Field == "SupplierCode").Select(e => e.GetType()).ToList());
        }
예제 #5
0
        public async void GivenModel_ManagerWillUpdateEntityRecord()
        {
            // Arrange
            var manager = new GenericManager <Word>(UoWFactoryMock.Object);

            UoW.Setup(m => m.CreateRepository <IGenericRepository <Word> >().Update(It.IsAny <Word>())).Verifiable();
            // Act
            await manager.UpdateAsync(word).ConfigureAwait(false);

            // Assert
            UoW.Verify(m => m.CreateRepository <IGenericRepository <Word> >().Update(It.Is <Word>(it => it.Id == word.Id)));
        }
예제 #6
0
        public void ExceptionErrorIsReturned()
        {
            // Assemble
            var request = TestData.GetCreateCompanyProductRequest();

            UoW.Setup(m => m.Save())
            .Throws <Exception>();

            // Act
            var result = Subject.CreateCompanyProduct(request);

            // Assert
            Assert.Contains(typeof(ExceptionError), result.Errors.Select(e => e.GetType()).ToList());
        }
예제 #7
0
        public async void GivenModelId_ManagerFindsEntity()
        {
            // Arrange
            var manager = new GenericManager <Word>(UoWFactoryMock.Object);

            UoW.Setup(m => m.CreateRepository <IGenericRepository <Word> >().FindByIdAsync(It.IsAny <int>()))
            .Returns(Task.FromResult(word)).Verifiable();
            // Act
            await manager.FindByIdAsync(betId).ConfigureAwait(false);

            // Assert
            UoW.Verify(m =>
                       m.CreateRepository <IGenericRepository <Word> >().FindByIdAsync(It.Is <int>(it => it == word.Id)));
        }
예제 #8
0
        public async void GivenNothing_ManagerReturnsAllRecords()
        {
            // Arrange
            var manager = new GenericManager <Word>(UoWFactoryMock.Object);

            UoW.Setup(m => m.CreateRepository <IGenericRepository <Word> >().AllAsync())
            .Returns(Task.FromResult(new List <Word> {
                word
            }));
            // Act
            var records = await manager.GetAllAsync().ConfigureAwait(false);

            // Assert
            Assert.Single(records);
            Assert.Equal(records[0].Id, betId);
        }