コード例 #1
0
        public void ConstructorWithError()
        {
            Assert.Throws <MyException>(() => new ClassWithPassword("hi!"));

            var secret = new ClassWithPassword("12345");

            Assert.Equal(42u, secret.GetSpecialValueFromInstance());
        }
コード例 #2
0
        public void GetStructAcceptsGoodPassword()
        {
            var result = ClassWithPassword.GetStruct("12345");

            Assert.Equal(41, result.Test);
            Assert.Equal(StructureEnum.Var2, result.FirstEnumValue);
            Assert.Equal(1, result.Int1);
            Assert.False(result.Bool2);
            Assert.Equal(StructureEnum.Var2, result.SecondEnumValue);
        }
コード例 #3
0
 public void ThrowsBadPassword()
 {
     try
     {
         ClassWithPassword.GetSpecialValue("hi!");
         Assert.True(false);
     }
     catch (MyException ex)
     {
         Assert.Equal(MyError.BadPassword, ex.error);
     }
 }
コード例 #4
0
        public void EchoPasswordAcceptsGoodPassword()
        {
            var result = ClassWithPassword.EchoPassword("12345");

            Assert.Equal("12345", result);
        }
コード例 #5
0
 public void EchoPasswordThrowsOnBadPassword()
 {
     Assert.Throws <MyException>(() => ClassWithPassword.EchoPassword("hi!"));
 }
コード例 #6
0
 public void GetStructThrowsOnBadPassword()
 {
     Assert.Throws <MyException>(() => ClassWithPassword.GetStruct("hi!"));
 }
コード例 #7
0
 public void AcceptsGoodPassword()
 {
     Assert.Equal(42u, ClassWithPassword.GetSpecialValue("12345"));
 }