public void TestUserCollection() { const int Count = 10; var collection1 = new DummyCollection <int>(); var collection2 = new DummyCollection <KeyValuePair <int, int> >(); for (var i = 0; i < Count; ++i) { collection1.Add(i); collection2.Add(new KeyValuePair <int, int>(i, i)); } var document = new A { Values1 = collection1, Values2 = collection2, }; var bson = document.ToBson(); var rehydrated = BsonSerializer.Deserialize <A>(bson); Assert.True(bson.SequenceEqual(rehydrated.ToBson())); Assert.Equal(10, rehydrated.Values1.Count); Assert.Equal(10, rehydrated.Values2.Count); }
public void SimpleNestedTest() { var dc = new DummyCollection(); var attr = new ObjectDialogAttribute(dc, "dummy", "d", "y"); attr.Update(); var output = attr.CurrentValue; Assert.AreEqual(DialogAttribute.ValueToLong("monkey"), output); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { if (IsInDesignMode) { Collection = new DummyCollection().Items; } AddFolderCommand = new RelayCommand(AddFolder); MakeIconsCommand = new RelayCommand(MakeIcons); WatchFolderCommand = new RelayCommand(WatchFolder); Messenger.Default.Register <GuiFilm>(this, "FilmLoadingChanged", (film) => { RaisePropertyChanged("FilmsLoadingCount"); RaisePropertyChanged("IsLoading"); RaisePropertyChanged("IsLoadingComplete"); RaisePropertyChanged("LoadingMessage"); }); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { if (IsInDesignMode) { Collection = new DummyCollection().Items; } AddFolderCommand = new RelayCommand(AddFolder); MakeIconsCommand = new RelayCommand(MakeIcons); WatchFolderCommand = new RelayCommand(WatchFolder); Messenger.Default.Register<GuiFilm>(this, "FilmLoadingChanged", (film) => { RaisePropertyChanged("FilmsLoadingCount"); RaisePropertyChanged("IsLoading"); RaisePropertyChanged("IsLoadingComplete"); RaisePropertyChanged("LoadingMessage"); }); }
public void NullCollection_should_not_serialize() { DummyCollection collection = new DummyCollection(); collection.Names = null; // serialize var serializeSettings = new JsonSerializerSettings(); serializeSettings.Initialize(); string json = JsonConvert.SerializeObject(collection, Formatting.None, serializeSettings); Assert.Equal(@"{}", json); // deserialize DummyCollection deserializedCollection = JsonConvert.DeserializeObject <DummyCollection>(json, serializeSettings); Assert.Null(deserializedCollection.Names); }
public void EmptyCollection_should_serialize() { DummyCollection collection = new DummyCollection(); collection.Names = new List <string>() { }; // serialize var serializeSettings = new JsonSerializerSettings(); serializeSettings.Initialize(); string json = JsonConvert.SerializeObject(collection, Formatting.None, serializeSettings); Assert.Equal(@"{""names"":[]}", json); // deserialize DummyCollection deserializedCollection = JsonConvert.DeserializeObject <DummyCollection>(json, serializeSettings); Assert.Equal(deserializedCollection.Names.Count, collection.Names.Count); }