Exemple #1
0
        public void IsValidForRequestTest()
        {
            var context = new Mock <ControllerContext>();

            context.SetupGet(c => c.HttpContext.Request.UrlReferrer).
            Returns(new Uri("http://www.wings.msn.to/Test/Previous"));
            context.SetupGet(c => c.HttpContext.Request.Url).
            Returns(new Uri("http://www.web-deli.com/Member/Create"));
            var info   = new Mock <MethodInfo>();
            var attr   = new ReferrerAttribute(true);
            var result = attr.IsValidForRequest(context.Object, info.Object);

            Assert.IsFalse(result);
        }
Exemple #2
0
        public void IsValidForRequestTest()
        {
            //ControllerContextクラスのモックを準備(リファラーとリクエストURLを設定)
            var context = new Mock <ControllerContext>();

            context.SetupGet(c => c.HttpContext.Request.UrlReferrer).Returns(new Uri("http://www.wings.msn.to/Test/Previous"));
            context.SetupGet(c => c.HttpContext.Request.Url).Returns(new Uri("http://www.web-deli.com/Member/Create"));

            //MethodInfoクラスのモックを準備
            var info = new Mock <MethodInfo>();

            //ReferrerAttributeクラスをインスタンス化&IsValidForRequestメソッドを実行
            var attr   = new ReferrerAttribute(true);
            var result = attr.IsValidForRequest(context.Object, info.Object);

            //メソッドの戻り値がfalseであることをチェック
            Assert.IsFalse(result);
        }
Exemple #3
0
        public void IsValidForRequestTest()
        {
            // Arrange
            var uri1 = new Uri("http://www.wings.msn.to/Test/Previous");
            var uri2 = new Uri("http://yahoo.co.jp/Member/Create");

            var context = new Mock <ControllerContext>();

            context.SetupGet <Uri>(c => c.HttpContext.Request.UrlReferrer).Returns(uri1);
            context.SetupGet <Uri>(c => c.HttpContext.Request.Url).Returns(uri2);

            var info = new Mock <MethodInfo>();
            var attr = new ReferrerAttribute(true);

            // Act
            var result = attr.IsValidForRequest(context.Object, info.Object);

            // Assert
            Assert.IsFalse(result);
        }