public void CheckEventLogEntry()
        {
            TestStepBuilder tsb = new TestStepBuilder("BizUnit.EventLogCheckStep", null);
            object[] args = new object[1];
            args[0] = "Application";
            tsb.SetProperty("EventLog", args);

            args = new object[1];
            args[0] = "VAA FFP";
            tsb.SetProperty("Source", args);

            args = new object[1];
            args[0] = "Error";
            tsb.SetProperty("EventType", args);

            args = new object[1];
            args[0] = 2028;
            tsb.SetProperty("EventId", args);

            args = new object[1];
            args[0] = "FieldValue: '3'";
            tsb.SetProperty("ValidationRegexs", args);

            BizUnitTestCase testCase = new BizUnitTestCase("FileCreateStepTest");
            testCase.AddTestStep(tsb, TestStage.Execution);
             
            BizUnit bizUnit = new BizUnit(testCase);
            bizUnit.RunTest();
        }
        public void FileCreateStepTest_Negative()
        {
            string testDirectory = @"..\..\..\Test\BizUnit.Tests\Out";
            FileHelper.EmptyDirectory(testDirectory, "*.xml");

            Assert.AreEqual(FileHelper.NumberOfFilesInDirectory(testDirectory, "*.xml"), 0);

            BizUnitTestCase testCase = new BizUnitTestCase("FileCreateStepTest_Negative");

            FileCreateStep fcs = new FileCreateStep();
            fcs.SourcePath = @"C:\GarbageDirectory__NoOneWouldHaveADirCalledThisSurely\LoadGenScript001.xml";
            fcs.CreationPath = testDirectory + @"\Data_%Guid%.xml";
            testCase.AddTestStep(fcs, TestStage.Execution);

            BizUnit bizUnit = new BizUnit(testCase);

            bool exceptionCaught = false;

            try
            {
                bizUnit.RunTest();
            }
            catch(DirectoryNotFoundException)
            {
                exceptionCaught = true;
            }

            Assert.IsTrue(exceptionCaught);
            Assert.AreEqual(FileHelper.NumberOfFilesInDirectory(testDirectory, "*.xml"), 0);
        }
        public void FileCreateStepTest()
        {
            string testDirectory = @"..\..\..\Test\BizUnit.Tests\Out";
            FileHelper.EmptyDirectory(testDirectory, "*.xml");
            
            Assert.AreEqual(FileHelper.NumberOfFilesInDirectory(testDirectory, "*.xml"), 0);

            BizUnitTestCase testCase = new BizUnitTestCase("FileCreateStepTest");

            FileCreateStep fcs = new FileCreateStep();
            fcs.SourcePath = @"..\..\..\Test\BizUnit.Tests\Data\LoadGenScript001.xml";
            fcs.CreationPath = testDirectory + @"\Data_%Guid%.xml";
            testCase.AddTestStep(fcs, TestStage.Execution);

            BizUnit bizUnit = new BizUnit(testCase);
            bizUnit.RunTest();

            Assert.AreEqual(FileHelper.NumberOfFilesInDirectory(testDirectory, "*.xml"), 1);
        }
        public void TestDisposeWithSteps()
        {
            Context context = new Context();
            context.DisposeMembersOnTestCaseCompletion = true;
            IDisposable disposable = mockery.DynamicMock<IDisposable>();
            IEnumerable notDisposable = mockery.DynamicMock<IEnumerable>();

            context.Add("DisposableClassKey", disposable);
            context.Add("NotDisposableClassKey", notDisposable);

            BizUnitTestCase testCase = new BizUnitTestCase("TestDisposeWithSteps");
            ITestStepOM mockStep1 = mockery.DynamicMock<ITestStepOM>();
            testCase.AddTestStep(mockStep1, TestStage.Setup);
            ITestStepOM mockStep2 = mockery.DynamicMock<ITestStepOM>();
            testCase.AddTestStep(mockStep2, TestStage.Execution);
            ITestStepOM mockStep3 = mockery.DynamicMock<ITestStepOM>();
            testCase.AddTestStep(mockStep3, TestStage.Cleanup);

            using (mockery.Record())
            {
                mockStep1.Execute(context);
                LastCall.Repeat.Once();

                mockStep2.Execute(context);
                LastCall.Repeat.Once();

                mockStep3.Execute(context);
                LastCall.Repeat.Once();

                disposable.Dispose();
                LastCall.Repeat.Once();
            }

            using (mockery.Playback())
            {
                BizUnit.BizUnit bizUnit = new BizUnit.BizUnit(testCase, context);
                bizUnit.RunTest();
            }
        }
Beispiel #5
0
        private void LoadObjectModelTestCaseAndInit(BizUnitTestCase testCase, TestGroupPhase phase, Context ctx)
        {
            if (null != ctx)
            {
                _context = ctx;
                _context.Initialize(this);
            }
            else
            {
                _context = new Context(this);
                _logger = _context.Logger;
            }

            _testGroupPhase = phase;
            _testName = testCase.Name;
            DateTime now = DateTime.Now;

            if (phase == TestGroupPhase.Unknown)
            {
                _logger.TestStart(_testName, now, GetUserName());                
                _context.Add(BizUnitTestCaseStartTime, now);
            }
            else
            {
                _logger.TestGroupStart(_testName, phase, now, GetUserName());
            }

            _testCaseObjectModel = testCase;
        }
Beispiel #6
0
        public BizUnit(BizUnitTestCase testCase, Context ctx)
        {
            ArgumentValidation.CheckForNullReference(testCase, "testCase");

            _logger = ctx.Logger;
            LoadObjectModelTestCaseAndInit(testCase, TestGroupPhase.Unknown, ctx);
        }
Beispiel #7
0
        public BizUnit(BizUnitTestCase testCase)
        {
            ArgumentValidation.CheckForNullReference(testCase, "testCase");

            LoadObjectModelTestCaseAndInit(testCase, TestGroupPhase.Unknown, null);
        }
        public void ObjectModelMixedWithConfigTest()
        {
            string config = ResourceLoaderHelper.GetResourceData("Data", "FileMoveConfig.xml");
            string testDirectory = @"..\..\..\Test\BizUnit.Tests\Out";
            FileHelper.EmptyDirectory(testDirectory, "*.xml");

            Assert.AreEqual(FileHelper.NumberOfFilesInDirectory(testDirectory, "*.xml"), 0);

            BizUnitTestCase testCase = new BizUnitTestCase("ObjectModelMixedWithConfigTest");

            // Add an object model defined BizUnit step...
            FileCreateStep fcs = new FileCreateStep();
            fcs.SourcePath = @"..\..\..\Test\BizUnit.Tests\Data\LoadGenScript001.xml";
            fcs.CreationPath = testDirectory + @"\InDoc1.xml";
            testCase.AddTestStep(fcs, TestStage.Execution);

            // Add a config defined BizUnit step...
            FileMoveStep fms = new FileMoveStep();
            testCase.AddTestStep(fms, config, TestStage.Execution);

            BizUnit bizUnit = new BizUnit(testCase);
            bizUnit.RunTest();

            Assert.AreEqual(FileHelper.NumberOfFilesInDirectory(testDirectory, "*.xml"), 1);
        }