Beispiel #1
0
        public void ReportingEngine_LoadReportFilePath_MissingAppConfigKey_ShouldThrowException()
        {
            // ARRANGE
            ReportingEngine engine     = null;
            string          resultPath = string.Empty;

            this._mockConfigurationProvider.Setup(x => x.HasKey("ReportFile")).Returns(false);

            engine = this.CreateEngineUsingFakes();

            // ACT
            // No act because we're checking an exception

            // ASSERT
            Assert.Throws <ArgumentException>(() => resultPath = engine.LoadReportFilePath(), "The method should have thrown an exception.");
            Assert.IsEmpty(resultPath, "No path should have been assigned.");
        } // end test
Beispiel #2
0
        public void ReportingEngine_LoadReportFilePath_WithValidConfigEntry_ShouldLoadFullPath()
        {
            // ARRANGE
            ReportingEngine engine       = null;
            string          resultPath   = string.Empty;
            string          expectedPath = Path.Combine(Environment.CurrentDirectory, "myfile.txt");

            this._mockConfigurationProvider.Setup(x => x.HasKey("ReportFile")).Returns(true);
            this._mockConfigurationProvider.Setup(x => x.GetValue <string>("ReportFile")).Returns("myfile.txt");
            this._mockFileSystemProvider.Setup(x => x.BuildPath(It.IsAny <string[]>())).Returns(expectedPath);

            engine = this.CreateEngineUsingFakes();

            // ACT
            resultPath = engine.LoadReportFilePath();

            // ASSERT
            Assert.IsNotEmpty(resultPath, "The path should have been returned.");
            Assert.AreEqual(expectedPath, resultPath, "The returned path wasn't what it should have been.");
        } // end test