public void SetItemAndGetItemWorksAsExpected() { // --- Arrange var context = new ServiceCallContext(); context.Clear(); // --- Act context.Set(new IntContextItem(123)); var item1 = context.Get <IntContextItem>(); context.Set(new StringContextItem("hello")); var item2 = context.Get <StringContextItem>(); var item3 = context.Get <EmptyContextItem>(); // --- Assert item1.ShouldNotBeNull(); item1.Value.ShouldEqual(123); var contextItem = item1 as IServiceCallContextItem; contextItem.ShouldNotBeNull(); contextItem.GetValue().ShouldEqual(123); item2.ShouldNotBeNull(); item2.Value.ShouldEqual("hello"); item3.ShouldBeNull(); }
public void RemoveWorksAsExpected() { // --- Arrange var context = new ServiceCallContext(); context.Clear(); context.Set(new IntContextItem(123)); // --- Act var item1 = context.Get <IntContextItem>(); context.Remove <IntContextItem>(); var item2 = context.Get <IntContextItem>(); // --- Assert item1.ShouldNotBeNull(); item2.ShouldBeNull(); }