//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotBotherSerializingToRealBytesIfFarFromThreshold() public virtual void ShouldNotBotherSerializingToRealBytesIfFarFromThreshold() { // given Layout<GenericKey, NativeIndexValue> layout = mock( typeof( Layout ) ); doThrow( typeof( Exception ) ).when( layout ).newKey(); GenericIndexKeyValidator validator = new GenericIndexKeyValidator( 120, layout ); // when validator.Validate( new Value[]{ intValue( 10 ), epochDate( 100 ), stringValue( "abc" ) } ); // then no exception should have been thrown }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldInvolveSerializingToRealBytesIfMayCrossThreshold() public virtual void ShouldInvolveSerializingToRealBytesIfMayCrossThreshold() { // given Layout<GenericKey, NativeIndexValue> layout = mock( typeof( Layout ) ); when( layout.NewKey() ).thenReturn(new CompositeGenericKey(3, SpatialSettings())); GenericIndexKeyValidator validator = new GenericIndexKeyValidator( 48, layout ); // when try { validator.Validate( new Value[]{ intValue( 10 ), epochDate( 100 ), stringValue( "abcdefghijklmnopqrstuvw" ) } ); fail( "Should have failed" ); } catch ( System.ArgumentException e ) { // then good assertThat( e.Message, containsString( "abcdefghijklmnopqrstuvw" ) ); verify( layout, times( 1 ) ).newKey(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportCorrectValidationErrorsOnRandomlyGeneratedValues() public virtual void ShouldReportCorrectValidationErrorsOnRandomlyGeneratedValues() { // given int slots = Random.Next( 1, 6 ); int maxLength = Random.Next( 15, 30 ) * slots; GenericLayout layout = new GenericLayout( slots, SpatialSettings() ); GenericIndexKeyValidator validator = new GenericIndexKeyValidator( maxLength, layout ); GenericKey key = layout.NewKey(); int countOk = 0; int countNotOk = 0; for ( int i = 0; i < 100; i++ ) { // when Value[] tuple = GenerateValueTuple( slots ); bool isOk; try { validator.Validate( tuple ); isOk = true; countOk++; } catch ( System.ArgumentException ) { isOk = false; countNotOk++; } int actualSize = actualSize( tuple, key ); bool manualIsOk = actualSize <= maxLength; // then if ( manualIsOk != isOk ) { fail( format( "Validator not validating %s correctly. Manual validation on actual key resulted in %b whereas validator said %b", Arrays.ToString( tuple ), manualIsOk, isOk ) ); } } }