ValidateDdex() private method

private ValidateDdex ( string releaseType, string version, string xmlMessage ) : System.Web.Mvc.ActionResult
releaseType string
version string
xmlMessage string
return System.Web.Mvc.ActionResult
コード例 #1
0
        public void ValidateDdexWithXmlFile()
        {
            // Arrange
            var validator = new Mock<IDdexValidator>();
            var controller = new HomeController(validator.Object);
            var xmlMessage = TestSettings.Default.EmptyXml;

            var context = new Mock<ControllerContext>();
            var server = new Mock<HttpServerUtilityBase>();
            var request = new Mock<HttpRequestBase>();
            var files = new Mock<HttpFileCollectionBase>();
            var enc = new UTF8Encoding();

            var file1 = new Mock<HttpPostedFileBase>();
            file1.Setup(d => d.FileName).Returns("AudioSingle.33.xml");
            file1.Setup(d => d.InputStream).Returns(new MemoryStream(enc.GetBytes(Resources.AudioSingle_33)));
            file1.Setup(d => d.ContentLength).Returns(enc.GetBytes(Resources.AudioSingle_33).Length);

            context.Setup(x => x.HttpContext.Request).Returns(request.Object);
            context.Setup(x => x.HttpContext.Server).Returns(server.Object);
            context.Setup(x => x.HttpContext.Request.Files.Count).Returns(1);
            context.Setup(x => x.HttpContext.Request.Files[0]).Returns(file1.Object);
            controller.ControllerContext = context.Object;
            validator.Setup(x => x.Transform(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns("");

            // Act
            var result = controller.ValidateDdex("Audio Single", "10", xmlMessage) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #2
0
        public void ValidateDdexWithXmlText()
        {
            // Arrange
            var validator = new Mock<IDdexValidator>();
            var controller = new HomeController(validator.Object);
            var xmlMessage = TestSettings.Default.EmptyXml;

            var context = new Mock<ControllerContext>();
            var server = new Mock<HttpServerUtilityBase>();
            var request = new Mock<HttpRequestBase>();
            var files = new Mock<HttpFileCollectionBase>();

            context.Setup(x => x.HttpContext.Request).Returns(request.Object);
            context.Setup(x => x.HttpContext.Server).Returns(server.Object);
            context.Setup(x => x.HttpContext.Request.Files).Returns(files.Object);
            context.Setup(x => x.HttpContext.Request.Files.Count).Returns(0);
            controller.ControllerContext = context.Object;
            validator.Setup(x => x.Transform(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns("");

            // Act
            var result = controller.ValidateDdex("Audio Single", "10", xmlMessage) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }