示例#1
0
        public void Run_InvalidFlagValue_ShouldThrowItemException(string flagValue)
        {
            //arrange
            const string expectedError   = "Unknown flag value";
            Item         fakeContextItem = ItemHelper.CreateItem("GAG_GECO ChangeControlled", string.Empty);

            Item fakeAffectedItem = ItemHelper.CreateItem("GAG_GrammerChangeControlled", "get");

            fakeAffectedItem.setProperty("gag_migration_edit_flag", flagValue);

            IDataAccessLayer fakeDal = Substitute.For <IDataAccessLayer>();

            fakeDal.ApplyItem(Arg.Any <Item>()).Returns(fakeAffectedItem);
            fakeDal.NewItem("GAG_GrammerChangeControlled", "get").Returns(fakeAffectedItem);
            fakeDal.NewError(Arg.Any <string>()).Returns(ci =>
            {
                Item error = ItemHelper.CreateItem(string.Empty, string.Empty);
                error.loadAML(string.Format(CultureInfo.CurrentCulture, ErrorResultTemplate, ci.ArgAt <string>(0)));
                return(error);
            });
            var testClass = new TestClass(fakeDal);

            //act
            //assert
            ItemException exception   = Assert.Throws <ItemException>(() => testClass.Run(fakeContextItem));
            string        actualError = exception?.ErrorItem?.getErrorString();

            Assert.AreEqual(actualError, expectedError);
        }
示例#2
0
        public void Run_MigrationFlagIs1_ShouldReturnContextItem()
        {
            //arrange
            Item fakeContextItem = ItemHelper.CreateItem("GAG_GECO ChangeControlled", string.Empty);

            fakeContextItem.setNewID();

            Item fakeAffectedItem = ItemHelper.CreateItem("GAG_GrammerChangeControlled", "get");

            fakeAffectedItem.setProperty("gag_migration_edit_flag", "1");

            IDataAccessLayer fakeDal = Substitute.For <IDataAccessLayer>();

            fakeDal.ApplyItem(Arg.Any <Item>()).Returns(fakeAffectedItem);
            fakeDal.NewItem("GAG_GrammerChangeControlled", "get").Returns(fakeAffectedItem);
            var testClass = new TestClass(fakeDal);

            //act
            Item result = testClass.Run(fakeContextItem);

            //assert
            Assert.AreEqual(result.getID(), fakeContextItem.getID());
        }