/// <summary> /// Serializes the specified item in the default location. /// </summary> /// <param name="items">The items to serialize.</param> /// <exception cref="System.NotImplementedException"></exception> public void Serialize(IEnumerable<IItem> items) { Check.IfIsNull(items).Throw<ArgumentNullException>(() => items); if (!IsProjectLoaded) return; var serializableItem = new SerializableItemCollection(items); var serializableItemToString = xmlSerializer.Serialize(serializableItem); Logger.Log(Resources.ItemEditorLoggerCategory, "Serialized Items: {0}", serializableItemToString); fileWriter.Write(serializableItemToString, GetDefaultLocation()); }
public void WhenItemCollectionIsValidItWillInitializeCollection() { var items = new List<IItem> { new StubIItem(), new StubIItem(), new StubIItem(), new StubIItem(), new StubIItem(), }; var collection = new SerializableItemCollection(items); Assert.AreEqual(items.Count, collection.Count); }
public void WhenProjectIsLoadedWillReturnItemsCollection() { var project = new StubIProject(); var projectLoader = new StubIProjectLoader { CurrentProjectGet = () => project }; var itemsCollection = new List<IItem> {new StubIItem()}; var serializableItemCollection = new SerializableItemCollection(itemsCollection); var xmlDeserializer = new StubIXmlDeserializer(); xmlDeserializer.DeserializeOf1String(s => serializableItemCollection); var deserializedCollection = SetupClassWithDefaults(projectLoader, xmlDeserializer).Deserialize(); Assert.AreEqual(itemsCollection.Count, deserializedCollection.Count()); }