public void AddGetUpdateGetDeleteGetUser() { var userName = "******"; simpleChatContext = new SqliteSimpleChatContext(databaseSettings); simpleChatContext.Database.EnsureCreated(); var user = new User { Name = userName }; AddItem(user); var userFromDb = simpleChatContext.Users.Find(1); Assert.NotNull(userFromDb); Assert.Equal(userName, userFromDb.Name); UpdateItem(userFromDb); userFromDb = simpleChatContext.Users.Find(1); Assert.NotNull(userFromDb); Assert.Equal(userName, userFromDb.Name); DeleteItem(userFromDb); userFromDb = simpleChatContext.Users.Find(1); Assert.Null(userFromDb); }
public void AddGetUpdateGetDeleteGetMessage() { simpleChatContext = new SqliteSimpleChatContext(databaseSettings); simpleChatContext.Database.EnsureCreated(); var user = new User { Name = "admin", Email = "*****@*****.**" }; AddItem(user); var message = new Message { UserId = 1, Text = "Message text" }; AddItem(message); var messageFromDb = simpleChatContext.Messages.Find(1); Assert.NotNull(messageFromDb); Assert.Equal("Message text", messageFromDb.Text); Assert.Equal(1, messageFromDb.UserId); messageFromDb.Text = "Another message text"; UpdateItem(messageFromDb); messageFromDb = simpleChatContext.Messages.Find(1); Assert.NotNull(messageFromDb); Assert.Equal("Another message text", messageFromDb.Text); Assert.Equal(1, messageFromDb.UserId); DeleteItem(messageFromDb); messageFromDb = simpleChatContext.Messages.Find(1); Assert.Null(messageFromDb); }
public void Constructor_ConnenctionStringIsWhiteSpace_ExceptionThrown() { databaseSettings.ConnectionString = " "; Assert.Throws <ArgumentException>(() => simpleChatContext = new SqliteSimpleChatContext(databaseSettings)); }
public void Constructor_NullSettings_ExceptionThrown() { Assert.Throws <ArgumentNullException>(() => simpleChatContext = new SqliteSimpleChatContext(null)); }