public void ItShouldWork() { var x = new EnumerationFlags(StatesSample.One); x.AddFlag(StatesSample.Three); var json = JsonConvert.SerializeObject(x); var y = JsonConvert.DeserializeObject <EnumerationFlags>(json); Assert.Equal(2, y.SelectedKeys.Count); Assert.Equal(StatesSample.Three, StatesSample.GetInstanceFromKey(y.SelectedKeys.Last())); }
public void ItShouldNotThrowAnError() { var x = new EnumerationAndFlags(StatesSample.One); Assert.Null(x.AllEnumerations); var json = JsonConvert.SerializeObject(x); var y = JsonConvert.DeserializeObject <EnumerationAndFlags>(json); Assert.Single(y.SelectedKeys); Assert.Equal(StatesSample.One, StatesSample.GetInstanceFromKey(y.SelectedKeys.Last())); Assert.Null(x.AllEnumerations); }
public void ItShouldNotThrowAnError() { var x = new TypedEnumerationAndFlags <StatesSample>(StatesSample.One, true) { AllowMultipleSelections = true }; x.AddFlag(StatesSample.Three); var json = JsonConvert.SerializeObject(x); var y = JsonConvert.DeserializeObject <EnumerationAndFlags>(json); Assert.Equal(2, y.SelectedKeys.Count); Assert.Equal(StatesSample.Three, StatesSample.GetInstanceFromKey(y.SelectedKeys.Last())); Assert.Equal(3, y.AllEnumerations.Count); Assert.Equal(StatesSample.One, y.AllEnumerations.First()); }