Skip to content

Commit

Permalink
Added properties.ToDictionary()
Browse files Browse the repository at this point in the history
  • Loading branch information
sschmid committed Apr 10, 2017
1 parent 213ac71 commit 4bdd5d9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -43,6 +43,10 @@ public void RemoveKey(string key) {
_dict.Remove(key);
}

public Dictionary<string, string> ToDictionary() {
return new Dictionary<string, string>(_dict);
}

static string convertLineEndings(string str) {
return str.Replace("\r\n", "\n").Replace("\r", "\n");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Entitas.Utils;
using NSpec;

Expand Down Expand Up @@ -233,6 +233,29 @@ void when_creating_properties() {
values.should_contain("some value 2 ");
values.should_contain("some value 3");
};

it["gets a dictionary"] = () => {
var input =
"some.key.1=some value 1" + "\n" +
" some.key.2 = some value 2 " + "\n" +
"some.key.3=some value 3" + "\n";

var dict = new Properties(input).ToDictionary();
dict.Count.should_be(3);
dict.ContainsKey("some.key.1").should_be_true();
dict.ContainsKey("some.key.2").should_be_true();
dict.ContainsKey("some.key.3").should_be_true();
};

it["gets a dictionary copy"] = () => {
var input =
"some.key.1=some value 1" + "\n" +
" some.key.2 = some value 2 " + "\n" +
"some.key.3=some value 3" + "\n";

var properties = new Properties(input);
properties.ToDictionary().should_not_be_same(properties.ToDictionary());
};
};

context["when replacing special characters in values"] = () => {
Expand Down

0 comments on commit 4bdd5d9

Please sign in to comment.