コード例 #1
0
        public void LnkReactivateClick_IfDataTableSelectMethodReturnsValue_CreatesEventHandlerAssociations(
            string expectedExpression,
            string expectedEventHandlerId,
            string expectedName,
            string expectedClassName,
            int expectedEventId,
            string expectedLogMessage)
        {
            // Arrange
            SetupShimEvents(expectedExpression);

            var passedGuid      = Guid.Empty;
            var passedName      = string.Empty;
            var passedClassName = string.Empty;
            var passedEventId   = default(int);

            ShimEventHandlersDataSet.Constructor = instance =>
            {
                var shimHandlerDataSet   = new ShimEventHandlersDataSet(instance);
                var shimHandlerDataTable = new ShimEventHandlersDataTable();
                shimHandlerDataTable.AddEventHandlersRowGuidStringStringStringInt32StringInt32 =
                    (eventHandlerId, name, assemblyName, className, eventId, description, order) =>
                {
                    passedGuid      = eventHandlerId;
                    passedName      = name;
                    passedClassName = className;
                    passedEventId   = eventId;

                    return(null);
                };

                shimHandlerDataSet.EventHandlersGet = () => shimHandlerDataTable.Instance;
            };

            var passedMessage = string.Empty;

            ShimEventLog.AllInstances.WriteEntryStringEventLogEntryTypeInt32 =
                (instance, message, logType, eventId) => passedMessage       = message;

            ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = code => code();

            // Act
            _testEntityPrivate.Invoke("lnkReactivate_Click", this, EventArgs.Empty);

            // Assert
            _testEntity.ShouldSatisfyAllConditions(
                () => passedGuid.ShouldBe(new Guid(expectedEventHandlerId)),
                () => passedName.ShouldBe(expectedName),
                () => passedClassName.ShouldBe(expectedClassName),
                () => passedEventId.ShouldBe(expectedEventId),
                () => passedMessage.ShouldBe(expectedLogMessage));
        }
コード例 #2
0
        private void SetupShimEvents(string expectedFilterExpression)
        {
            var shimEventHandlerDataSet   = new ShimEventHandlersDataSet();
            var shimEventHandlerDataTable = new ShimEventHandlersDataTable();
            var shimDataTable             = new ShimDataTable(shimEventHandlerDataTable.Instance);

            shimDataTable.SelectString = filterExpression =>
            {
                return(filterExpression == expectedFilterExpression
                    ? new DataRow[0]
                    : new DataRow[1]);
            };

            shimEventHandlerDataSet.EventHandlersGet             = () => shimEventHandlerDataTable;
            ShimEvents.AllInstances.ReadEventHandlerAssociations = _ => shimEventHandlerDataSet;
            ShimEvents.AllInstances.CreateEventHandlerAssociationsEventHandlersDataSet = (_1, _2) => { };
            ShimEvents.AllInstances.UrlSetString = (_1, _2) => { };
            ShimEvents.AllInstances.UseDefaultCredentialsSetBoolean = (_1, _2) => { };
        }