Esempio n. 1
0
        public void Suppliers_Create()
        {
            // Arrange
            db = new AlexaDbContextTest();
            supplierService = new SupplierService(new SupplierRepositoryTest(db), new GroupRepositoryTest(db));
            groupService    = new GroupService(new SupplierRepositoryTest(db), new GroupRepositoryTest(db));
            controller      = new SuppliersController(supplierService, groupService);

            var supplier = new SupplierDto
            {
                ID      = 5,
                Name    = "test",
                Address = "test",
                Email   = "test",
                Phone   = "123 456 789",
                Groups  = new List <GroupDto>()
                {
                    groupService.GetById(0)
                }
            };

            // Act
            ViewResult result_1 = controller.Create(supplier) as ViewResult;
            ViewResult result_2 = controller.Details(5) as ViewResult;

            // Assert
            Assert.IsNotNull(result_2);
            Assert.IsInstanceOfType(result_2.ViewData.Model, typeof(SupplierDto));
            var supplier_edit = (SupplierDto)result_2.ViewData.Model;

            Assert.AreEqual(supplier_edit.Name, "test");
        }
        public void DetailsTest()
        {
            TestDeploymentContext tdc = new TestDeploymentContext();

            //adding one contract, as the contract requires a supplier id
            ContractDetail x = new ContractDetail()
            {
                Contract_ID        = 0, Supplier_ID = 0, ContractStartDate = new DateTime(10, 05, 2019),
                ContractFinishDate = new DateTime(10, 05, 2020), Servicetype = Service.Waste, PriceDescription = "Hourly Price", Price = 22.00,
                VatRate            = 0.135, PriceUpdatedate = new DateTime(01 / 01 / 2019)
            };

            tdc.ContractDetail.Add(x);
            Assert.IsNotNull(x);


            tdc.Supplier.Add(new Supplier()
            {
                Supplier_ID = 0, SupplierNumber = "SN000", SupplierName = "Tipperary Water", SupplierAddress = "5 Cherry Orchard Industrial Estate, Ballyfermot, Dublin 10.", SupplierCounty = "Dublin", SupplierContact = "Lana kelly", SupplierEMail = "*****@*****.**"
            });
            var controller = new SuppliersController(tdc);
            var result     = controller.Details(0);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Supplier y = new Supplier();

            //(Supplier)((ViewResult)result).Model;
            Assert.AreEqual(y.SupplierName, "Tipperary Water");
        }
Esempio n. 3
0
        public void Suppliers_Details()
        {
            // Arrange
            db = new AlexaDbContextTest();
            supplierService = new SupplierService(new SupplierRepositoryTest(db), new GroupRepositoryTest(db));
            groupService    = new GroupService(new SupplierRepositoryTest(db), new GroupRepositoryTest(db));
            controller      = new SuppliersController(supplierService, groupService);

            // Act
            ViewResult result = controller.Details(0) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.ViewData.Model, typeof(SupplierDto));
            var supplier = (SupplierDto)result.ViewData.Model;

            Assert.AreEqual(supplier.Name, "Uklízečky.cz");
        }
Esempio n. 4
0
        public async Task Details_ReturnsViewResultWithSupplier()
        {
            // Arrange
            var supplier = new Supplier()
            {
                Id = 1
            };
            var mockRepo = new Mock <IInvoicesRepository>();

            mockRepo.Setup(repo => repo.GetSupplierAsync(supplier.Id)).ReturnsAsync(supplier);
            var controller = new SuppliersController(mockRepo.Object);

            // Act
            var result = await controller.Details(supplier.Id);

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <Supplier>(viewResult.ViewData.Model);

            Assert.Equal(supplier.Id, model.Id);
        }
Esempio n. 5
0
        public void Suppliers_EditSupplier()
        {
            // Arrange
            db = new AlexaDbContextTest();
            supplierService = new SupplierService(new SupplierRepositoryTest(db), new GroupRepositoryTest(db));
            groupService    = new GroupService(new SupplierRepositoryTest(db), new GroupRepositoryTest(db));
            controller      = new SuppliersController(supplierService, groupService);

            var supplier = supplierService.GetById(1);

            supplier.Name = "Papírna.cz - Edit";

            // Act
            ViewResult result_1 = controller.Edit(supplier) as ViewResult;
            ViewResult result_2 = controller.Details(1) as ViewResult;

            // Assert
            Assert.IsNotNull(result_2);
            Assert.IsInstanceOfType(result_2.ViewData.Model, typeof(SupplierDto));
            var supplier_edit = (SupplierDto)result_2.ViewData.Model;

            Assert.AreEqual(supplier_edit.Name, "Papírna.cz - Edit");
        }