public void TestSetOthers() { // Uncovered by other tests var dict = new MutableDictionaryObject(); dict.SetFloat("pi", 3.14f); dict.SetDouble("better_pi", 3.14159); dict.SetBoolean("use_better", true); dict.GetFloat("pi").Should().Be(3.14f); dict.GetDouble("better_pi").Should().Be(3.14159); dict.GetDouble("pi").Should().BeApproximately(3.14, 0.00001); dict.GetFloat("better_pi").Should().BeApproximately(3.14159f, 0.0000000001f); dict.GetBoolean("use_better").Should().BeTrue(); }
public void TestGetValueFromNewEmptyDictionary() { DictionaryObject dict = new MutableDictionaryObject(); dict.GetInt("key").Should().Be(0, "because that is the default value"); dict.GetLong("key").Should().Be(0L, "because that is the default value"); dict.GetDouble("key").Should().Be(0.0, "because that is the default value"); dict.GetBoolean("key").Should().Be(false, "because that is the default value"); dict.GetDate("key").Should().Be(DateTimeOffset.MinValue, "because that is the default value"); dict.GetBlob("key").Should().BeNull("because that is the default value"); dict.GetValue("key").Should().BeNull("because that is the default value"); dict.GetString("key").Should().BeNull("because that is the default value"); dict.GetDictionary("key").Should().BeNull("because that is the default value"); dict.GetArray("key").Should().BeNull("because that is the default value"); dict.ToDictionary().Should().BeEmpty("because the dictionary is empty"); var doc = new MutableDocument("doc1"); doc.SetDictionary("dict", dict); Db.Save(doc); var gotDoc = Db.GetDocument("doc1"); dict = gotDoc.GetDictionary("dict"); dict.GetInt("key").Should().Be(0, "because that is the default value"); dict.GetLong("key").Should().Be(0L, "because that is the default value"); dict.GetDouble("key").Should().Be(0.0, "because that is the default value"); dict.GetBoolean("key").Should().Be(false, "because that is the default value"); dict.GetDate("key").Should().Be(DateTimeOffset.MinValue, "because that is the default value"); dict.GetBlob("key").Should().BeNull("because that is the default value"); dict.GetValue("key").Should().BeNull("because that is the default value"); dict.GetString("key").Should().BeNull("because that is the default value"); dict.GetDictionary("key").Should().BeNull("because that is the default value"); dict.GetArray("key").Should().BeNull("because that is the default value"); dict.ToDictionary().Should().BeEmpty("because the dictionary is empty"); }