private void ServerOnClientMessage(NamedPipeConnection <TestCollection, TestCollection> connection, TestCollection message) { Logger.DebugFormat("Received collection with {0} items from the client", message.Count); _actualData = message; _actualHash = message.GetHashCode(); _barrier.Set(); }
public void TestCircularReferences() { _expectedData = new TestCollection(); for (var i = 0; i < 10; i++) { var item = new TestItem(i, _expectedData, RandomEnum()); _expectedData.Add(item); } _expectedHash = _expectedData.GetHashCode(); _client.PushMessage(_expectedData); _barrier.WaitOne(TimeSpan.FromSeconds(5)); if (_exceptions.Any()) { throw new AggregateException(_exceptions); } Assert.NotNull(_actualHash, string.Format("Server should have received client's {0} item message", _expectedData.Count)); Assert.AreEqual(_expectedHash, _actualHash, string.Format("Hash codes for {0} item message should match", _expectedData.Count)); Assert.AreEqual(_expectedData.Count, _actualData.Count, string.Format("Collection lengths should be equal")); for (var i = 0; i < _actualData.Count; i++) { var expectedItem = _expectedData[i]; var actualItem = _actualData[i]; Assert.AreEqual(expectedItem, actualItem, string.Format("Items at index {0} should be equal", i)); Assert.AreEqual(actualItem.Parent, _actualData, string.Format("Item at index {0}'s Parent property should reference the item's parent collection", i)); } }
public TestItem(int id, TestCollection parent, TestEnum @enum) { Id = id; Parent = parent; Enum = @enum; }