//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addTokenWithDuplicatedNotAllowed() public virtual void AddTokenWithDuplicatedNotAllowed() { TokenRegistry tokenCache = CreateTokenCache(); tokenCache.Put(new NamedToken(INBOUND1_TYPE, 1)); tokenCache.Put(new NamedToken(INBOUND2_TYPE, 2)); ExpectedException.expect(typeof(NonUniqueTokenException)); ExpectedException.expectMessage("The testType \"inbound1\" is not unique"); tokenCache.Put(new NamedToken(INBOUND1_TYPE, 3)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void keepOriginalTokenWhenAddDuplicate() public virtual void KeepOriginalTokenWhenAddDuplicate() { TokenRegistry tokenCache = CreateTokenCache(); tokenCache.Put(new NamedToken(INBOUND1_TYPE, 1)); tokenCache.Put(new NamedToken(INBOUND2_TYPE, 2)); TryToAddDuplicate(tokenCache); assertEquals(1, tokenCache.GetId(INBOUND1_TYPE).Value); assertEquals(2, tokenCache.GetId(INBOUND2_TYPE).Value); assertNull(tokenCache.GetToken(3)); }
private void TryToAddDuplicate(TokenRegistry tokenCache) { try { tokenCache.Put(new NamedToken(INBOUND1_TYPE, 3)); } catch (NonUniqueTokenException) { } }