Пример #1
0
        public void TestIfIsInsertingDPIResources()
        {
            // Arrange
            DateTime calculationDate = DateTime.Today;
            FakeObjectSet<CS_DPI> fakeDPI = new FakeObjectSet<CS_DPI>();
            fakeDPI.AddObject(new CS_DPI()
            {
                ID = 1,
                JobID = 1,
                Date = calculationDate,
                Active = true
            });

            FakeObjectSet<CS_Resource> fakeResource = new FakeObjectSet<CS_Resource>();
            fakeResource.AddObject(new CS_Resource()
            {
                ID = 1,
                JobID = 1,
                EquipmentID = 1
            });
            fakeResource.AddObject(new CS_Resource()
            {
                ID = 1,
                JobID = 1,
                EmployeeID = 1
            });

            FakeObjectSet<CS_DPIResource> fakeDPIResource = new FakeObjectSet<CS_DPIResource>();

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_DPI>()).Returns(fakeDPI);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Resource>()).Returns(fakeResource);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_DPIResource>()).Returns(fakeDPIResource);

            // Act
            DPIModel model = new DPIModel(mockUnitOfWork.Object);
            model.InsertDPIResources(calculationDate);

            // Assert
            Assert.AreEqual(2, fakeDPIResource.ToList().Count);
        }
Пример #2
0
        public void MustInsertNewDPIIfNewResourcesAreCreatedForTheJob()
        {
            //Arrange
            FakeObjectSet<CS_Resource> fakeResources = new FakeObjectSet<CS_Resource>();
            fakeResources.AddObject(new CS_Resource() { ID = 1, JobID = 1, Active = true, EquipmentID = 1298, Type = 1 });
            fakeResources.AddObject(new CS_Resource() { ID = 2, JobID = 1, Active = true, EmployeeID = 324972, Type = 2 });
            fakeResources.AddObject(new CS_Resource() { ID = 3, JobID = 1, Active = true, EquipmentID = 123, Type = 1 });

            FakeObjectSet<CS_DPI> fakeDPI = new FakeObjectSet<CS_DPI>();
            fakeDPI.AddObject(new CS_DPI() { ID = 1, Date = DateTime.Now, JobID = 1, Active = true });

            FakeObjectSet<CS_DPIResource> fakeDPIResources = new FakeObjectSet<CS_DPIResource>();
            fakeDPIResources.AddObject(new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 123, Active = true });

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Resource>()).Returns(fakeResources);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_DPIResource>()).Returns(fakeDPIResources);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_DPI>()).Returns(fakeDPI);

            DPIModel dpiModel = new DPIModel(mockUnitOfWork.Object);
            //Act
            dpiModel.InsertDPIResources(DateTime.Now);
            //Assert
            Assert.AreEqual(3, fakeDPIResources.Count());
        }