public void CanRetrieveEntries() { //arrange ScheduleDBContext context = MakeContext("RecentActivityTest"); ChatLog newLog = new ChatLog { TimeStamp = DateTime.Now, Chat = "This test string." }; ChatLog newLog2 = new ChatLog { TimeStamp = DateTime.Now, Chat = "Another test string" }; //act context.Add(newLog); context.Add(newLog2); context.SaveChanges(); //code matching controller method var result = from x in context.ChatLogs.Take(20) orderby x.TimeStamp descending select x; //assert Assert.Equal(2, result.Count()); //reset ResetContext(context); }
public void CanInsertMalware() { //arrange ScheduleDBContext context = MakeContext("ChatLogTest2"); ChatLog newLog = new ChatLog { TimeStamp = DateTime.Now, Chat = "{'chat': '{insert json malware here}'}" }; //act context.Add(newLog); context.SaveChanges(); var testResult = from x in context.ChatLogs select x; //assert Assert.NotNull(testResult); //reset ResetContext(context); }
public void CanPostChatLog() { //arrange ScheduleDBContext context = MakeContext("ChatLogTest"); ChatLog newLog = new ChatLog { TimeStamp = DateTime.Now, Chat = "This test string." }; //act context.Add(newLog); context.SaveChanges(); var testResult = from x in context.ChatLogs select x; //assert Assert.NotNull(testResult); //reset ResetContext(context); }