コード例 #1
0
        public void ShouldNotFindInspectorsAsync()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                //Act
                Inspector result = repositori.FindAsync(Guid.NewGuid()).Result;

                //Assert
                Assert.Null(result);
            }
        }
コード例 #2
0
        public void ShouldRetriveAllInspectorsAsync()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                //Act
                IEnumerable <Inspector> result = repositori.GetAllAsync().Result;

                //Assert
                Assert.Equal(3, result.Count());
            }
        }
コード例 #3
0
        public void ShouldFindInspector()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                //Act
                Inspector result = repositori.Find(testId);

                //Assert
                Assert.NotNull(result);
            }
        }
コード例 #4
0
        public void ShouldNotRetriveSingleInspectorAsync()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                //Act
                Inspector result = repositori.GetSingleAsync(o => o.Id == Guid.NewGuid()).Result;

                //Assert
                Assert.Null(result);
            }
        }
コード例 #5
0
        public void ShouldRetriveSingleInspector()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                //Act
                Inspector result = repositori.GetSingle(o => o.Id == testId);

                //Assert
                Assert.NotNull(result);
            }
        }
コード例 #6
0
        public void ShouldNotRetriveFilteredEagerInspectors()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                //Act
                IEnumerable <Inspector> result = repositori.GetFilteredAsync(o => o.Name == "anotherName").Result;

                //Assert
                Assert.Empty(result);
            }
        }
コード例 #7
0
        public void ShouldRetriveFilteredEagerInspectorsAsync()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                //Act
                IEnumerable <Inspector> result = repositori.GetFilteredAsync(o => o.Name == testName).Result;

                //Assert
                Assert.Single(result);
            }
        }
コード例 #8
0
        public void ShouldRemoveInspector()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                //Act
                repositori.Delete(testId);
                Inspector result = repositori.Find(testId);

                //Assert
                Assert.False(result.Active);
            }
        }
コード例 #9
0
        public UnitOfWork()
        {
            if (_context == null)
            {
                _context = new FestiSpecEntities();
            }

            Inspectors          = new InspectorRepository(_context);
            NawEmployee         = new NAWEmployeeRepository(_context);
            Employee            = new EmployeeRepository(_context);
            RoleEmployee        = new RoleEmployeeRepository(_context);
            NAWInspectors       = new NAWInspector_Repository(_context);
            Questionnaires      = new QuestionnaireRepository(_context);
            Inspections         = new InspectionRepository(_context);
            InspectionLocations = new LocationRepository(_context);
            Customers           = new CustomerRepository(_context);
            ContactPersons      = new ContactPersonRepository(_context);
            Certificates        = new CertificatesRepository(_context);
            NAWCustomers        = new NAWCustomerRepository(_context);
        }
コード例 #10
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            InspectorRepository ur = new InspectorRepository();
            var ok = await ur.Validar(context.UserName, context.Password);

            if (!ok)
            {
                context.SetError("Invalido", "El nombre de usuario o constraseña es incorrecto");
                return;
            }

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            identity.AddClaim(new Claim("sub", context.UserName));
            identity.AddClaim(new Claim("role", "user"));

            context.Validated(identity);
        }
コード例 #11
0
        public void ShouldCreateInpector()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                Inspector Inspector1 = new Inspector()
                {
                    Id      = Guid.NewGuid(),
                    Name    = "Customer 1",
                    Created = DateTime.Today
                };

                //Act
                repositori.Create(Inspector1);
                Inspector result = repositori.Find(Inspector1.Id);

                //Assert
                Assert.NotNull(result);
            }
        }
コード例 #12
0
        public void ShouldCreateWithInspectorInspector()
        {
            using (var context = InitAndGetDbContext())
            {
                //Arrange
                var repositori = new InspectorRepository(context);

                Inspector Inspector1 = new Inspector()
                {
                    Name = "Inspector 1", Created = DateTime.Today
                };
                Inspection Inspection1 = new Inspection()
                {
                    Customer     = "Customer 1",
                    Address      = "Address 1",
                    Observations = "Observation 1",
                    Status       = Status.Done,
                    Created      = DateTime.Today
                };
                InspectionInspector relation1 = new InspectionInspector()
                {
                    InspectionDate = DateTime.Today.AddDays(-1), InspectionId = Inspection1.Id, InspectorId = Inspector1.Id
                };
                Inspector1.InspectionInspector = new List <InspectionInspector>()
                {
                    relation1
                };

                //Act
                repositori.Create(Inspector1);
                Inspector result = repositori.Find(Inspector1.Id);

                //Assert
                Assert.NotNull(result);
            }
        }