public void OfType_OnContextValue_FiltersObjectsOfType() { var context = new NodeContext <NodeType>(); context.Add(null, new NodeType("fortytwo")); context.Add(null, new NodeSubType("sixsixsix")); context.GetAll().Of <NodeType>().Select(n => n.Name).Should().ContainInOrder("fortytwo", "sixsixsix"); context.GetAll().Of <NodeSubType>().Select(n => n.Name).Should().ContainInOrder("sixsixsix"); context.Get("none").Of <NodeSubType>().Should().BeEmpty(); }
public void Cast_ToCompatibleType_ReturnsCorrectType() { var context = new NodeContext <NodeType>(); context.Add("name", new NodeSubType("fortytwo")); context.Add("value", new NodeSubType("sixsixsix")); context.Get("name").Single <NodeSubType>().Name.Should().Be("fortytwo"); context.Get("name").Optional <NodeSubType>()?.Name.Should().Be("fortytwo"); context.Get("missing").Optional <NodeSubType>().Should().BeNull(); context.GetAll().As <NodeSubType>().Select(n => n.Name).Should().ContainInOrder("fortytwo", "sixsixsix"); }