public void TestSensitiveDataClearing() { var data = new MyData(); data.Nested = new NestedData(); data.ShallowString = "Shallow"; data.ShallowButNotSensitive = "ShallowNotSensitive"; data.Nested.NestedDeep = new NestedData2(); data.Nested.NestedDeep.SomeInt = 100; data.Nested.NestedDeep.SensitiveInt = 100; data.Nested.NestedDeep.SomeString = "Really Deep"; data.Nested.NestedDeep.SomeObject = new object(); data.ClearSensitiveData(); Assert.AreEqual(null,data.ShallowString); Assert.AreEqual(null, data.Nested.NestedDeep.SomeString); Assert.AreEqual(null, data.Nested.NestedDeep.SomeObject); Assert.AreEqual(100, data.Nested.NestedDeep.SomeInt); Assert.AreEqual(-1, data.Nested.NestedDeep.SensitiveInt); Assert.AreEqual("ShallowNotSensitive", data.ShallowButNotSensitive); }
public void TestSensitiveWithObservable() { Assert.Inconclusive("This test will fail until the Observable code generation supports passing through attributes"); return; var data = new MyData().Observable(); data.Nested = new NestedData(); data.ShallowString = "Shallow"; data.ShallowButNotSensitive = "ShallowNotSensitive"; data.Nested.NestedDeep = new NestedData2(); data.Nested.NestedDeep.SomeInt = 100; data.Nested.NestedDeep.SensitiveInt = 100; data.Nested.NestedDeep.SomeString = "Really Deep"; data.Nested.NestedDeep.SomeObject = new object(); int notifications = 0; (data as IObjectObservable).PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler((a, b) => { notifications++; }); data.ClearSensitiveData(); Assert.AreEqual(null, data.ShallowString); Assert.AreEqual(null, data.Nested.NestedDeep.SomeString); Assert.AreEqual(null, data.Nested.NestedDeep.SomeObject); Assert.AreEqual(100, data.Nested.NestedDeep.SomeInt); Assert.AreEqual(-1, data.Nested.NestedDeep.SensitiveInt); Assert.AreEqual("ShallowNotSensitive", data.ShallowButNotSensitive); Assert.AreEqual(7, notifications); }