public void FNVConfig_GetPredefinedConfig_ExpectedValues_Work() { foreach (var expectedPredefinedConfig in _expectedPredefinedConfigs) { var fnvConfig = FNVConfig.GetPredefinedConfig(expectedPredefinedConfig.HashSizeInBits); Assert.Equal(expectedPredefinedConfig.HashSizeInBits, fnvConfig.HashSizeInBits); Assert.Equal(expectedPredefinedConfig.Prime, fnvConfig.Prime); Assert.Equal(expectedPredefinedConfig.Offset, fnvConfig.Offset); } }
public void FNVConfig_GetPredefinedConfig_InvalidSizes_Throw() { var invalidHashSizes = new[] { 0, 1, 8, 16, 31, 33, 63, 65, 127, 255, 1023, 2048, 4096 }; foreach (var invalidHashSize in invalidHashSizes) { Assert.Equal( "hashSizeInBits", Assert.Throws <ArgumentOutOfRangeException>( () => FNVConfig.GetPredefinedConfig(invalidHashSize)) .ParamName); } }
public void FNV1aFactory_Create_Config_Works() { var fnvConfig = FNVConfig.GetPredefinedConfig(32); var fnv1aFactory = FNV1aFactory.Instance; var fnv1a = fnv1aFactory.Create(fnvConfig); Assert.NotNull(fnv1a); Assert.IsType <FNV1a_Implementation>(fnv1a); var resultingFNVConfig = fnv1a.Config; Assert.Equal(fnvConfig.HashSizeInBits, resultingFNVConfig.HashSizeInBits); Assert.Equal(fnvConfig.Prime, resultingFNVConfig.Prime); Assert.Equal(fnvConfig.Offset, resultingFNVConfig.Offset); }
public void FNV1Factory_Create_Works() { var defaultFNVConfig = FNVConfig.GetPredefinedConfig(64); var fnv1Factory = FNV1Factory.Instance; var fnv1 = fnv1Factory.Create(); Assert.NotNull(fnv1); Assert.IsType <FNV1_Implementation>(fnv1); var resultingFNVConfig = fnv1.Config; Assert.Equal(defaultFNVConfig.HashSizeInBits, resultingFNVConfig.HashSizeInBits); Assert.Equal(defaultFNVConfig.Prime, resultingFNVConfig.Prime); Assert.Equal(defaultFNVConfig.Offset, resultingFNVConfig.Offset); }
protected override IFNV1 CreateHashFunction(int hashSize) => new FNV1_Implementation( FNVConfig.GetPredefinedConfig(hashSize));