public void Append_NoItems_Success() { var stack = new ContextStack(); stack.Append("value"); Assert.Equal("value", stack[0]); }
public void Append_Context_Null() { ContextStack stack = new ContextStack(); try { stack.Append(null); Assert.Fail("#1"); } catch (ArgumentNullException ex) { Assert.AreEqual(typeof(ArgumentNullException), ex.GetType(), "#2"); Assert.IsNull(ex.InnerException, "#3"); Assert.IsNotNull(ex.Message, "#4"); Assert.AreEqual("context", ex.ParamName, "#5"); } }
public void IntegrityTest() { ContextStack stack = new ContextStack(); string one = "one"; string two = "two"; stack.Push(two); stack.Push(one); Assert.AreSame(one, stack [typeof(string)], "#1"); Assert.AreSame(one, stack [0], "#2"); Assert.AreSame(one, stack.Current, "#3"); Assert.AreSame(one, stack.Pop(), "#4"); Assert.AreSame(two, stack [typeof(string)], "#5"); Assert.AreSame(two, stack [0], "#6"); Assert.AreSame(two, stack.Current, "#7"); #if NET_2_0 string three = "three"; stack.Append(three); Assert.AreSame(two, stack[typeof(string)], "#8"); Assert.AreSame(two, stack[0], "#9"); Assert.AreSame(two, stack.Current, "#10"); Assert.AreSame(two, stack.Pop(), "#11"); Assert.AreSame(three, stack[typeof(string)], "#12"); Assert.AreSame(three, stack[0], "#13"); Assert.AreSame(three, stack.Current, "#14"); Assert.AreSame(three, stack.Pop(), "#15"); #else Assert.AreSame(two, stack.Pop(), "#15"); #endif Assert.IsNull(stack.Pop(), "#16"); Assert.IsNull(stack.Current, "#17"); }
public void IntegrityTest() { ContextStack stack = new ContextStack(); string one = "one"; string two = "two"; stack.Push(two); stack.Push(one); Assert.Same(one, stack[typeof(string)]); Assert.Same(one, stack[0]); Assert.Same(one, stack.Current); Assert.Same(one, stack.Pop()); Assert.Same(two, stack[typeof(string)]); Assert.Same(two, stack[0]); Assert.Same(two, stack.Current); string three = "three"; stack.Append(three); Assert.Same(two, stack[typeof(string)]); Assert.Same(two, stack[0]); Assert.Same(two, stack.Current); Assert.Same(two, stack.Pop()); Assert.Same(three, stack[typeof(string)]); Assert.Same(three, stack[0]); Assert.Same(three, stack.Current); Assert.Same(three, stack.Pop()); Assert.Null(stack.Pop()); Assert.Null(stack.Current); }
public void Append_Context_Null() { ContextStack stack = new ContextStack(); ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => stack.Append(null)); Assert.Equal(typeof(ArgumentNullException), ex.GetType()); Assert.Null(ex.InnerException); Assert.NotNull(ex.Message); Assert.Equal("context", ex.ParamName); }
public void Append_Context_Null() { ContextStack stack = new ContextStack(); ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => stack.Append(null)); Assert.Equal(typeof(ArgumentNullException), ex.GetType()); Assert.Null(ex.InnerException); if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away exception messages and paramnames. { Assert.NotNull(ex.Message); Assert.Equal("context", ex.ParamName); } }