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 RemoveByKeyWorksAsExpected() { // --- Arrange var context = new ServiceCallContext(); context.Clear(); context.SetByKey("key1", 123); // --- Act var item1 = context.GetByKey("key1"); context.RemoveByKey("key1"); var item2 = context.GetByKey("key1"); // --- Assert item1.ShouldNotBeNull(); item2.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(); }
public void SetByKeyAndGetByKeyWorksAsExpected() { // --- Arrange var context = new ServiceCallContext(); context.Clear(); // --- Act context.SetByKey("key1", 123); var item1 = context.GetByKey("key1"); context.SetByKey("key2", "hello"); var item2 = context.GetByKey("key2"); var item3 = context.GetByKey("key3"); // --- Assert item1.ShouldNotBeNull(); item1.ShouldEqual(123); item2.ShouldNotBeNull(); item2.ShouldEqual("hello"); item3.ShouldBeNull(); }