Esempio n. 1
0
        public void SaveChunkData()
        {
            // arrange
            var handler = new FileUploadHandler();
            int savedButes;

            Mock.Arrange(() => handler.IsFinalFileRequest()).Returns(false);

            // act
            var result = handler.SaveChunkData(@"D:\1.txt", 1, new byte[0], 10, out savedButes);

            // assert
            Assert.IsFalse(result);

            // arrange
            Mock.Arrange(() => handler.IsFinalFileRequest()).Returns(true);
            Mock.Arrange(() => handler.GetQueryParameter((Constants.ReplaceReportConnectionStrings))).Returns("bla-bla-bla (not bool value)");

            // act
            result = handler.SaveChunkData(@"D:\1.txt", 1, new byte[0], 10, out savedButes);

            // assert
            Assert.IsFalse(result);

            // arrange
            Mock.Arrange(() => handler.GetQueryParameter((Constants.ReplaceReportConnectionStrings))).Returns("false");

            // act
            result = handler.SaveChunkData(@"D:\1.txt", 1, new byte[0], 10, out savedButes);

            // assert
            Assert.IsFalse(result);
        }
Esempio n. 2
0
        public void SaveChunkDataTest()
        {
            // arrange
            var handler = new FileUploadHandler();

            int x;
            Mock.Arrange(() => new RadUploadHandler().SaveChunkData(string.Empty, 0, Arg.IsAny<byte[]>(), 0, out x)).IgnoreInstance().DoInstead(() =>
                {
                    Mock.Arrange(() => handler.IsFinalFileRequest()).Returns(true);
                    Mock.Arrange(() => handler.GetQueryParameter((Constants.ReplaceReportConnectionStrings))).Returns("true");
                }).Returns(true);

            var called = false;
            Mock.Arrange(() => ReportUploadHelper.ReplaceReportConnectionStrings(Arg.AnyString)).DoInstead(() => called = true);

            // act
            var result = handler.SaveChunkData(string.Empty, 0, new byte[0], 0, out x);

            // assert
            Assert.IsTrue(result);
            Assert.IsTrue(called);
        }