コード例 #1
0
        public void Get_GuidExists_ReturnsTemplate()
        {
            //Arrange
            var options = new DbContextOptionsBuilder()
                          .UseInMemoryDatabase(databaseName: "Get_GuidExists_ReturnTemplate")
                          .Options;

            using (TemplateContext context = new TemplateContext(options))
            {
                //Act
                Template _template = new Template()
                {
                    Id           = new Guid("05D5FD46-263E-E211-BFBA-1040F3A7A3B1"),
                    Name         = "Prueba",
                    Description  = "Descripción de la entidad de prueba",
                    AddedDate    = DateTime.Now,
                    ModifiedDate = DateTime.Now,
                    IsActive     = true
                };
                context.Add(_template);
                context.SaveChanges();

                //SUT
                var SUT = new ClassFinderRepository(context);

                //Assert
                Assert.NotNull(SUT.Get(_template.Id));
            }
        }
コード例 #2
0
        public void GetByName_NameNotExists_ReturnEmptyListTemplate()
        {
            //Arrange
            var options = new DbContextOptionsBuilder()
                          .UseInMemoryDatabase(databaseName: "Get_NameNotExists_ReturnEmptyListTemplate")
                          .Options;

            using (TemplateContext context = new TemplateContext(options))
            {
                //Act
                Template _template = new Template()
                {
                    Id           = new Guid("00000000-0000-0000-0000-000000000000"),
                    Name         = "Prueba",
                    Description  = "Descripción de la entidad de prueba",
                    AddedDate    = DateTime.Now,
                    ModifiedDate = DateTime.Now,
                    IsActive     = true
                };
                context.Add(_template);
                context.SaveChanges();

                //SUT
                var SUT = new ClassFinderRepository(context);

                //Assert
                Assert.Empty(SUT.GetByName("Prueba_1"));
            }
        }
コード例 #3
0
        public void GetAll_ExecuteAsEnumerable_ReturnsIEnumerableTemplate()
        {
            //Arrange
            var options = new DbContextOptionsBuilder()
                          .UseInMemoryDatabase(databaseName: "GetAll_ExecuteAsEnumerable_ReturnsIEnumerableTemplate")
                          .Options;

            using (TemplateContext context = new TemplateContext(options))
            {
                //Act
                List <Template> lstTemplates = new List <Template>();

                lstTemplates.Add(new Template()
                {
                    Name         = "Jorge",
                    Description  = "Ingeniero de Software",
                    IsActive     = true,
                    AddedDate    = DateTime.Now,
                    ModifiedDate = DateTime.Now
                });

                context.AddRange(lstTemplates);
                context.SaveChanges();
            }

            using (TemplateContext context = new TemplateContext(options))
            {
                //SUT
                var SUT = new ClassFinderRepository(context);

                //Assert
                Assert.NotEmpty(SUT.GetAll());
            }
        }
コード例 #4
0
        public void GetAll_ExecuteAsEnummerable_ReturnsIEnumerableTemplateEmpty()
        {
            //Arrange
            var options = new DbContextOptionsBuilder()
                          .UseInMemoryDatabase(databaseName: "GetAll_ExecuteAsEnummerable_ReturnsIEnumerableTemplateEmpty")
                          .Options;

            using (TemplateContext context = new TemplateContext(options))
            {
                //SUT
                var SUT = new ClassFinderRepository(context);

                //Assert
                Assert.Empty(SUT.GetAll());
            }
        }
コード例 #5
0
        public void Get_NotFoundGuid_ReturnNullObjectTemplate()
        {
            //Arrange
            var options = new DbContextOptionsBuilder()
                          .UseInMemoryDatabase(databaseName: "Get_NotFoundGuid_ReturnNullObjectTemplate")
                          .Options;

            using (TemplateContext context = new TemplateContext(options))
            {
                Template _template = new Template()
                {
                    Id = new Guid("00000000-0000-0000-0000-000000000000")
                };

                //SUT
                var SUT = new ClassFinderRepository(context);

                //Assert
                Assert.Null(SUT.Get(_template.Id));
            }
        }