public void Set_MultipleSettings_ReturnsSame() { // arrange var memorySettings = new MemorySettings(); var expectedValueA = "Cat"; var expectedValueB = "Dog"; var expectedValueC = "Bird"; var settings = new[] { new KeyValuePair <string, string>("Setting A", expectedValueA), new KeyValuePair <string, string>("Setting B", expectedValueB), new KeyValuePair <string, string>("Setting C", expectedValueC) }; // act memorySettings.Set(settings); var retrievedA = memorySettings.Get("Setting A", out string actualValueA); var retrievedB = memorySettings.Get("Setting B", out string actualValueB); var retrievedC = memorySettings.Get("Setting C", out string actualValueC); // assert Assert.True(retrievedA); Assert.Equal(expectedValueA, actualValueA); Assert.True(retrievedB); Assert.Equal(expectedValueB, actualValueB); Assert.True(retrievedC); Assert.Equal(expectedValueC, actualValueC); }
public void Set_NullSettingValue_Removes() { // arrange var memorySettings = new MemorySettings(); // act memorySettings.Set("String Setting", "Value 1"); memorySettings.Set("String Setting", (string)null); var retrieved = memorySettings.Get("String Setting", out string actualValue); // assert Assert.False(retrieved); }
public void Get_NonExistingSetting_ReturnsFalse() { // arrange var memorySettings = new MemorySettings(); var expected = default(string); // act var retrieved = memorySettings.Get("NonExistingSetting", out string actual); // assert Assert.False(retrieved); Assert.Equal(expected, actual); }
public void Set_IntegerNumber_ReturnsSame(string setting, int expected) { // arrange var memorySettings = new MemorySettings(); // act memorySettings.Set(setting, expected); var retrieved = memorySettings.Get(setting, out int actual); // assert Assert.True(retrieved); Assert.Equal(expected, actual); }
public void Get_DoubleNumber_ReturnsSame() { // arrange var memorySettings = new MemorySettings(); var expected = Math.PI; // act memorySettings.Set("PI", expected); var retrieved = memorySettings.Get("PI", out double actual); // assert Assert.True(retrieved); Assert.Equal(expected, actual); }
public void Set_EmptySettingValue_ReturnSame() { // arrange var memorySettings = new MemorySettings(); var expectedValue = string.Empty; // act memorySettings.Set("String Setting", "Value 1"); memorySettings.Set("String Setting", expectedValue); var retrieved = memorySettings.Get("String Setting", out string actualValue); // assert Assert.True(retrieved); Assert.Equal(expectedValue, actualValue); }