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)); } }
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")); } }
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()); } }
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()); } }
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)); } }