public void Replace_ReplacedAndEventRaised() { TestDataManager dm = new TestDataManager(); TestDataType data1 = new TestDataType { Id = 1U }, data2 = new TestDataType { Id = 2U }; dm.Add(data1); TestDataObserver obs = new TestDataObserver(); using IDisposable unsubscriber = dm.Subscribe(obs); Assert.AreEqual(dm.Get(1U), data1); dm.ReplaceData(new HashSet <TestDataType> { data2 }); Assert.AreEqual(dm.Get(2U), data2); Assert.AreEqual(0, obs.CompleteCount); Assert.AreEqual(0, obs.Errors.Count); Assert.AreEqual(1, obs.Next.Count); DataChanged <TestDataType> change = obs.Next.Dequeue(); Assert.IsTrue(change.Action == DataChangedAction.Replace && change.OldItems?.FirstOrDefault() == data1 && change.NewItems?.FirstOrDefault() == data2); }
public void GetAdded_ReturnsNotNull() { TestDataManager dm = new TestDataManager(); dm.Add(new TestDataType { Id = 1U }); Assert.IsNotNull(dm.Get(1U)); }
public void GetWithoutAdd_ReturnsNull() { TestDataManager dm = new TestDataManager(); Assert.IsNull(dm.Get(0U)); }