//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void doubleFreeMustThrow() internal virtual void DoubleFreeMustThrow() { int id = _set.allocate(new DummyPageSwapper("a", 42)); _set.free(id); System.InvalidOperationException exception = assertThrows(typeof(System.InvalidOperationException), () => _set.free(id)); assertThat(exception.Message, containsString("double free")); }
public void GetCatalogTest() { Catalog c1 = new Catalog("1", "Basnie braci Grimm", "Bracia Grimm"); DataRepository repo = new DataRepository(); repo.AddCatalog(c1); Assert.AreEqual(c1, repo.GetCatalog(c1.ID)); System.InvalidOperationException e = Assert.ThrowsException <System.InvalidOperationException>(() => repo.GetCatalog("sth")); }
public void GetClientTest() { Client c1 = new Client("1", "Jan", "Kowalski"); DataRepository repo = new DataRepository(); repo.AddClient(c1); Assert.AreEqual(c1, repo.GetClient(c1.ID)); System.InvalidOperationException e = Assert.ThrowsException <System.InvalidOperationException>(() => repo.GetClient("sth")); }
public void AssignClientAuthorityNoServer() { InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => { identity.AssignClientAuthority(server.localConnection); }); Assert.That(ex.Message, Is.EqualTo("AssignClientAuthority can only be called on the server for spawned objects")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotAllowCheckDiffReferenceAfterSkip() internal virtual void ShouldNotAllowCheckDiffReferenceAfterSkip() { // given _referenceCheck.skip(); // when System.InvalidOperationException exception = assertThrows(typeof(System.InvalidOperationException), () => _referenceCheck.checkDiffReference(new PropertyRecord(0), new PropertyRecord(0), null)); assertEquals("Reference has already been checked.", exception.Message); }
public void RestSharpResponseShouldReturnExceptionFromWrappedResult() { var ex = new System.InvalidOperationException(); var response = new Mock <IRestResponse <int> >(); response.Setup(x => x.ErrorException).Returns(ex); var tested = new RestSharpResponse <int>(response.Object); Assert.AreEqual(ex, tested.GetException()); }
public void RemoveclientAuthorityNotSpawned() { InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => { // shoud fail because the server is not active identity.RemoveClientAuthority(); }); Assert.That(ex.Message, Is.EqualTo("RemoveClientAuthority can only be called on the server for spawned objects")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void putAllNoOverwriteMustThrowOnConflict() internal virtual void PutAllNoOverwriteMustThrowOnConflict() { IDictionary <string, Value> target = new Dictionary <string, Value>(); IDictionary <string, Value> source = new Dictionary <string, Value>(); target["a"] = Values.intValue(1); source["a"] = Values.intValue(2); System.InvalidOperationException e = assertThrows(typeof(System.InvalidOperationException), () => IndexConfigProvider.putAllNoOverwrite(target, source)); assertEquals("Adding config would overwrite existing value: key=a, newValue=Int(2), oldValue=Int(1)", e.Message); }
public void RemoveClientAuthorityOfOwner() { server.AddPlayerForConnection(server.localConnection, gameObject); InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => { identity.RemoveClientAuthority(); }); Assert.That(ex.Message, Is.EqualTo("RemoveClientAuthority cannot remove authority for a player object")); }
public void GetInventoryTest() { Catalog c1 = new Catalog("1", "Ojciec Chrzestny", "Mario Putzo"); DataRepository repo = new DataRepository(); repo.AddCatalog(c1); Inventory i1 = new Inventory(repo.GetCatalog(c1.ID), 5); repo.AddInventory(i1); Assert.AreEqual(i1, repo.GetInventory(c1.ID)); System.InvalidOperationException e = Assert.ThrowsException <System.InvalidOperationException>(() => repo.GetInventory("sth")); }
public void AssignNullAuthority() { // create a networkidentity with our test component server.Spawn(gameObject); // someone might try to remove authority by assigning null. // make sure this fails. InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => { identity.AssignClientAuthority(null); }); Assert.That(ex.Message, Is.EqualTo("AssignClientAuthority for " + gameObject + " owner cannot be null. Use RemoveClientAuthority() instead")); }
public void ReassignClientAuthority() { // create a networkidentity with our test component server.Spawn(gameObject); // assign authority identity.AssignClientAuthority(server.localConnection); // shouldn't be able to assign authority while already owned by // another connection InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => { identity.AssignClientAuthority(new NetworkConnectionToClient(null)); }); Assert.That(ex.Message, Is.EqualTo("AssignClientAuthority for " + gameObject + " already has an owner. Use RemoveClientAuthority() first")); }
public async Task <ActionResult> Register(TRegistrationModel model) { // var model = this.CreateModel(); // this.TryUpdateModel(model); if (!this.ModelState.IsValid) { return(this.View(model)); } // If we got this far, something failed, redisplay form var user = this.CreateUserFromRegistrationModel(model); var result = await this.UserManager.CreateAsync(user, model.Password); if (!result.Succeeded) { this.AddErrors(result); return(this.View(model)); } #if !NETCORE var userIdentity = user.Id; await this.SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); #else var userIdentity = user; await this.SignInManager.SignInAsync(user, false, null); #endif // Send an email with confirmation link string code = await this.UserManager.GenerateEmailConfirmationTokenAsync(userIdentity); #if !NETCORE || SUPPORT_SMTP try { await this.SendRegistrationEmail(user, code); } catch (SmtpException ex) { var exceptionToPublish = new System.InvalidOperationException( string.Format("The sending email failed for the user {0}", user.Email), ex); ExceptionHelper.PublishException("system", exceptionToPublish); } #endif return(this.RedirectToAction("Index", "Home")); }
public void DeleteEventTest() { DataRepository repo = new DataRepository(); Client client = new Client("1", "Jan", "Kowalski"); repo.AddClient(client); Catalog c1 = new Catalog("1", "Basnie braci Grimm", "Bracia Grimm"); repo.AddCatalog(c1); Inventory i1 = new Inventory(repo.GetCatalog(c1.ID), 5); repo.AddInventory(i1); Event e1 = new Rent(client, i1, new System.DateTime(), new System.DateTime(2020, 1, 1)); repo.AddEvent(e1); repo.DeleteEvent(e1.ID); System.InvalidOperationException e = Assert.ThrowsException <System.InvalidOperationException>(() => repo.GetEvent(e1.ID)); }