Beispiel #1
0
        public void DeleteNonexistentLoad()
        {
            //Automapper
            AutoMapperConfig.RegisterMappings();

            //Mock context
            Mock <FortuneDbContext> mockContext = new Mock <FortuneDbContext>();

            //Mock repos
            Mock <IRepo <Load> > mockLoadRepo = new Mock <IRepo <Load> >();

            //Mock Calls
            mockLoadRepo.Setup(x => x.Get(It.IsAny <Guid>())).Returns <Load>(null);

            //Mock unit of work
            Mock <IUnitOfWork> mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.SetupGet(x => x.LoadRepo).Returns(mockLoadRepo.Object);

            //Load service
            LoadService loadService = new LoadService(mockUnitOfWork.Object);

            //Test
            loadService.Delete(Guid.NewGuid());
        }
Beispiel #2
0
        public void DeleteLoad()
        {
            //Automapper
            AutoMapperConfig.RegisterMappings();

            //Mock context
            Mock <FortuneDbContext> mockContext = new Mock <FortuneDbContext>();

            //Mock repos
            Mock <IRepo <Load> > mockLoadRepo = new Mock <IRepo <Load> >();

            //Test Load
            Load testLoad = new Load
            {
                Appointment   = DateTime.UtcNow,
                ArrivalTime   = DateTime.UtcNow,
                CfNum         = 1,
                Deleted       = false,
                DepartureTime = DateTime.UtcNow,
                DestinationId = Guid.NewGuid(),
                Id            = Guid.NewGuid(),
                OriginId      = Guid.NewGuid(),
                PuNum         = 1,
                Status        = LoadStatus.InTransit,
                TrailerId     = 1,
                Type          = LoadType.Inbound
            };


            //Mock Calls
            mockLoadRepo.Setup(x => x.Get(It.Is <Guid>(y => y == testLoad.Id))).Returns(testLoad);

            //Mock unit of work
            Mock <IUnitOfWork> mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.SetupGet(x => x.LoadRepo).Returns(mockLoadRepo.Object);

            //Load service
            LoadService loadService = new LoadService(mockUnitOfWork.Object);

            //Test
            loadService.Delete(testLoad.Id);
        }