public void CreateQuestionCreatesQuestion() { //arrange var options = new DbContextOptionsBuilder <DatLib.Entities.ecgbhozpContext>() .UseInMemoryDatabase("CreateQuestionCreatesQuestion") .Options; int questionId = 1; string questionString = "This is Question?"; int titleId = 1; var questionLog = new LogLibMod.Question { QuestionId = questionId, QuestionString = questionString, TitleId = titleId }; using var actContext = new DatLib.Entities.ecgbhozpContext(options); var repo = new CreateQuizRepository(actContext); //act repo.CreateQuestion(questionLog); repo.Save(); using var assertContext = new DatLib.Entities.ecgbhozpContext(options); var question = assertContext.Question.FirstOrDefault(); //assert Assert.Equal(expected: questionId + questionString + titleId, actual: question.QuestionId + question.QuestionString + question.TitleId); }
//class to entity public static Entities.Question MapQuestion(LogLib.Question question) { return(new Entities.Question { QuestionId = question.QuestionId, TitleId = question.TitleId, QuestionString = question.QuestionString, }); }