public void Load_ParameterIsNullOrWhiteSpace_ShouldThrowArgumentException(string jsonString) { // Arrange var loader = new IconMappingPresetsLoader(); // Act/Assert Assert.Throws <ArgumentNullException>(() => loader.Load(jsonString)); }
public void Load_ParameterContainsOnlyWhiteSpaceChararcters_ShouldThrow() { // Arrange var jsonString = @"\t\t\t \t"; var loader = new IconMappingPresetsLoader(); // Act/Assert Assert.ThrowsAny <Exception>(() => loader.Load(jsonString)); }
public void Load_FilePathIsNullOrWhiteSpace_ShouldThrow(string filePath) { // Arrange IconMappingPresetsLoader loader = new IconMappingPresetsLoader(); // Act var ex = Assert.Throws <ArgumentNullException>(() => loader.Load((string)filePath)); // Assert Assert.NotNull(ex); }
public void Load_StreamIsNull_ShouldThrow() { // Arrange IconMappingPresetsLoader loader = new IconMappingPresetsLoader(); // Act var ex = Assert.Throws <ArgumentNullException>(() => loader.Load((Stream)null)); // Assert Assert.NotNull(ex); }
public void Load_FileHasVersionAndOneMapping_ShouldReturnListWithOneMapping() { // Arrange var loader = new IconMappingPresetsLoader(); var content = "{\"Version\":\"0.1\",\"IconNameMappings\":[{\"IconFilename\":\"icon.png\",\"Localizations\":{\"eng\":\"mapped name\"}}]}"; // Act var result = loader.Load(content); // Assert Assert.Single(result.IconNameMappings); Assert.Equal("0.1", result.Version); }
public void Load_FileHasNoVersionAndOneMapping_ShouldReturnListWithOneMapping() { // Arrange var loader = new IconMappingPresetsLoader(); var content = "[{\"IconFilename\":\"icon.png\",\"Localizations\":{\"eng\":\"mapped name\"}}]"; var streamWithIconMapping = new MemoryStream(Encoding.UTF8.GetBytes(content)); // Act var result = loader.Load(streamWithIconMapping); // Assert Assert.Single(result.IconNameMappings); Assert.Equal(string.Empty, result.Version); }