public void TestUpdateService()
        {
            ServiceContext c          = new ServiceContext();
            var            fakeRepo   = new FakeServicesRepository();
            var            controller = new ServicesController(fakeRepo, c);
            var            Service    = new ServiceModel()
            {
                ServiceID          = 0,
                ServiceName        = "SomeJob",
                ServiceDescription = "FAKE REPO TEST",
                ServiceEstimated   = "more for testing the repo fake",
                ServicePrice       = 80,
                User = new User()
                {
                    UserId = "1", UserName = "******", UserLast = "Fake2"
                },
            };
            var Service2 = new ServiceModel()
            {
                ServiceID          = 1,
                ServiceName        = "Test2",
                ServiceDescription = "FAKE REPO TEST2",
                ServiceEstimated   = "more for testing the repo fake2",
                ServicePrice       = 80,
                User = new User()
                {
                    UserId = "1", UserName = "******", UserLast = "Fake2"
                },
            };
            var Service3 = new ServiceModel()
            {
                ServiceID          = 1,
                ServiceName        = "Test3",
                ServiceDescription = "FAKE REPO TEST3",
                ServiceEstimated   = "more for testing the repo fake3",
                ServicePrice       = 80,
                User = new User()
                {
                    UserId = "1", UserName = "******", UserLast = "Fake2"
                },
            };

            //Act
            controller.Edit(Service);
            controller.Edit(Service2);
            controller.Edit(Service3);
            //Assert
            // Assert Checking that story was added.
            ServiceModel retrievedService = fakeRepo.service.ToList()[0];

            Assert.Equal("FAKE REPO TEST3", retrievedService.ServiceDescription);
        }
        public void TestGetByIdService()
        {
            ServiceContext c          = new ServiceContext();
            var            fakeRepo   = new FakeServicesRepository();
            var            controller = new ServicesController(fakeRepo, c);
            var            Service    = new ServiceModel()
            {
                ServiceID          = 0,// Add the item will put the count for that
                ServiceName        = "SomeJob",
                ServiceDescription = "FAKE REPO TEST",
                ServiceEstimated   = "more for testing the repo fake",
                ServicePrice       = 80,
                User = new User()
                {
                    UserId = "1", UserName = "******", UserLast = "Fake2"
                },
            };
            var Service2 = new ServiceModel()
            {
                ServiceID          = 0,// Add the item will put the count for that
                ServiceName        = "Test2",
                ServiceDescription = "FAKE REPO TEST2",
                ServiceEstimated   = "more for testing the repo fake2",
                ServicePrice       = 80,
                User = new User()
                {
                    UserId = "1", UserName = "******", UserLast = "Fake2"
                },
            };
            var Service3 = new ServiceModel()
            {
                ServiceID          = 0,// Add the item will put the count for that
                ServiceName        = "Test3",
                ServiceDescription = "FAKE REPO TEST3",
                ServiceEstimated   = "more for testing the repo fake3",
                ServicePrice       = 80,
                User = new User()
                {
                    UserId = "1", UserName = "******", UserLast = "Fake2"
                },
            };

            //Act
            controller.Edit(Service);
            controller.Edit(Service2);
            controller.Edit(Service3);
            //Assert
            // Assert Checking that story was added.
            ServiceModel Service4 = fakeRepo.GetServiceById(2); // that should retrieve Service3

            Assert.Equal("FAKE REPO TEST3", Service4.ServiceDescription);
        }
        public void TestRemove()
        {
            //Arrange
            ServiceContext c          = new ServiceContext();
            var            fakeRepo   = new FakeServicesRepository();
            var            controller = new ServicesController(fakeRepo, c);
            var            Service    = new ServiceModel()
            {
                ServiceID          = 0,
                ServiceName        = "SomeJob",
                ServiceDescription = "FAKE REPO TEST",
                ServiceEstimated   = "more for testing the repo fake",
                ServicePrice       = 80,
                User = new User()
                {
                    UserId = "1", UserName = "******", UserLast = "Fake2"
                },
            };

            //Act
            controller.Edit(Service);   // adds
            controller.Delete(Service); // and deletes

            // Assert Checking that story was added.

            Assert.Empty(fakeRepo.service);
        }
        public void TestAdd()
        {
            //Arrange
            ServiceContext c          = new ServiceContext();
            var            fakeRepo   = new FakeServicesRepository();
            var            controller = new ServicesController(fakeRepo, c);
            var            Service    = new ServiceModel()
            {
                ServiceID          = 0,
                ServiceName        = "SomeJob",
                ServiceDescription = "FAKE REPO TEST",
                ServiceEstimated   = "more for testing the repo fake",
                ServicePrice       = 80,
                User = new User()
                {
                    UserId = "1", UserName = "******", UserLast = "Fake2"
                },
            };

            //Act
            controller.Edit(Service);

            // Assert Checking that story was added.
            var retrievedService = fakeRepo.service.ToList()[0];

            Assert.NotNull(retrievedService.ServiceName);
        }
Beispiel #5
0
        public async void Edit_ReturnNotFound(int serviceID)
        {
            var controller = new ServicesController(Context, UserManager);

            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = PrestadorLog
            };
            var result = await controller.Edit(serviceID);

            Assert.IsType <NotFoundResult>(result);
        }
Beispiel #6
0
        public async void Edit_ReturnViewResult(int serviceID)
        {
            var controller = new ServicesController(Context, UserManager);

            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = PrestadorLog
            };
            var result = await controller.Edit(serviceID);

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

            Assert.NotNull(model);
            Assert.Equal(serviceID, model.ServiceID);
        }
Beispiel #7
0
        public async void EditPost_ReturnNotFound(int serviceID)
        {
            var serviceUpdate = new Service {
                ServiceID = 4, UserID = "2", ServiceCategoryID = 1, ServiceName = "Limpeza de portas", Description = "Limpeza de Portas de Tarde"
            };

            Assert.Equal("Limpeza de Portas", Context.Service.Find(4).ServiceName);
            Assert.NotEqual(Context.Service.Find(4).Description, serviceUpdate.ServiceName);

            var controller = new ServicesController(Context, UserManager);

            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = PrestadorLog
            };
            var result = await controller.Edit(serviceID, serviceUpdate);

            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.Equal("/Views/Shared/NotFound.cshtml", viewResult.ViewName);
        }