public void CreateCategoryCreatesCategory() { //arrange var options = new DbContextOptionsBuilder <DatLib.Entities.ecgbhozpContext>() .UseInMemoryDatabase("CreateCategoryCreatesCategory") .Options; int categoryId = 1; string categoryString = "CategoryString"; string categoryDescription = "Desc"; int titleId = 1; var categoryLog = new LogLibMod.Category { CategoryId = categoryId, CategoryString = categoryString, CategoryDescription = categoryDescription, TitleId = titleId }; using var actContext = new DatLib.Entities.ecgbhozpContext(options); var repo = new CreateQuizRepository(actContext); //act repo.CreateCategory(categoryLog); repo.Save(); using var assertContext = new DatLib.Entities.ecgbhozpContext(options); var category = assertContext.Category.FirstOrDefault(); //assert Assert.Equal(expected: categoryId + categoryString + categoryDescription + titleId, actual: category.CategoryId + category.CategoryString + category.CategoryDescription + category.TitleId); }
//class to entity public static Entities.Category MapCategory(LogLib.Category category) { return(new Entities.Category { CategoryId = category.CategoryId, TitleId = category.TitleId, //this needs to be manually searched and inserted before getting here. Rank = category.Rank, CategoryString = category.CategoryString, CategoryDescription = category.CategoryDescription }); }