public void UpdateDatabaseGivenExistingId() { //arrange var options = Utils.GetDbOptions("EditLobbyShould_UpdateDatabaseGivenExistingId"); using (var context = new ApplicationDbContext(options)) { context.Lobbies.Add(new Lobby { ID = 5, Name = "Test", Private = false }); context.SaveChanges(); } //act using (var context = new ApplicationDbContext(options)) { var chatService = new Mock <IChatService>(); var service = new LobbyService(context, null, null); service.EditLobby(5, "GoodName", true); } //assert using (var context = new ApplicationDbContext(options)) { Assert.True(context.Lobbies.Find(5).Private); Assert.Equal("GoodName", context.Lobbies.Find(5).Name); } }
public void ThrowExceptionGivenIdOutOfRange() { //arrange var options = Utils.GetDbOptions("EditLobbyShould_ThrowExceptionGivenIdOutOfRange"); //act & assert using (var context = new ApplicationDbContext(options)) { var service = new LobbyService(context, null, null); Assert.Throws <ArgumentOutOfRangeException>(() => service.EditLobby(5, "SomeLobby", true)); } }