Ejemplo n.º 1
0
        public void ToolsetDefinitionLocationsIsConfiguration()
        {
            var projectCollection = new ProjectCollection(ToolsetDefinitionLocations.ConfigurationFile);
            IDictionary <string, string> toolsetProperties
                = new Dictionary <string, string>();

            foreach (Toolset toolset in projectCollection.Toolsets)
            {
                foreach (KeyValuePair <string, ProjectPropertyInstance> properties in toolset.Properties)
                {
                    toolsetProperties[properties.Value.Name] = properties.Value.EvaluatedValue;
                }
            }

            toolsetProperties.ShouldContainKey("MSBuildSDKsPath");
            toolsetProperties.ShouldContainKey("RoslynTargetsPath");
            toolsetProperties["MSBuildSDKsPath"].ShouldNotBeNullOrEmpty();
            toolsetProperties["RoslynTargetsPath"].ShouldNotBeNullOrEmpty();

            toolsetProperties.ShouldContainKey("VCTargetsPath");
            toolsetProperties.ShouldContainKey("MSBuildToolsRoot");
            toolsetProperties.ShouldContainKey("MSBuildExtensionsPath");
            toolsetProperties["VCTargetsPath"].ShouldNotBeNullOrEmpty();
            toolsetProperties["MSBuildToolsRoot"].ShouldNotBeNullOrEmpty();
            toolsetProperties["MSBuildExtensionsPath"].ShouldNotBeNullOrEmpty();
        }
        public void TwoDistributionWithFiveContinuationsAfterTwoSplits()
        {
            _mapper.AddInitialDistributionAndContinuation(0);
            _mapper.ProbabilisticSplit(0, 1, 3);
            _mapper.NonDeterministicSplit(1, 4, 5);


            var existingDistributions = new Dictionary <int, bool>();
            var entries = CountEntriesAndAddDistributionsToMap(0, existingDistributions);

            entries.ShouldBe(0);

            entries = CountEntriesAndAddDistributionsToMap(1, existingDistributions);
            entries.ShouldBe(0);

            entries = CountEntriesAndAddDistributionsToMap(2, existingDistributions);
            entries.ShouldBe(2);

            entries = CountEntriesAndAddDistributionsToMap(3, existingDistributions);
            entries.ShouldBe(2);

            entries = CountEntriesAndAddDistributionsToMap(4, existingDistributions);
            entries.ShouldBe(1);

            entries = CountEntriesAndAddDistributionsToMap(5, existingDistributions);
            entries.ShouldBe(1);

            existingDistributions.Count.ShouldBe(2);
            existingDistributions.ShouldContainKey(0);
            existingDistributions.ShouldContainKey(1);
        }
Ejemplo n.º 3
0
        public async Task Should_contain_the_same_payloads()
        {
            var publishObserver = new BusTestPublishObserver(TimeSpan.FromSeconds(3));

            using (Bus.ConnectPublishObserver(publishObserver))
            {
                await Bus.Publish(new A());

                IPublishedMessage <A> a = publishObserver.Messages.Select <A>().FirstOrDefault();
                IPublishedMessage <B> b = publishObserver.Messages.Select <B>().FirstOrDefault();

                a.ShouldNotBeNull();
                b.ShouldNotBeNull();

                Dictionary <string, object> ah = a.Context.Headers.GetAll().ToDictionary(x => x.Key, x => x.Value);
                Dictionary <string, object> bh = b.Context.Headers.GetAll().ToDictionary(x => x.Key, x => x.Value);

                ah.ShouldContainKey("x-send-filter");
                ah.ShouldContainKey("x-send-message-filter");
                ah["x-send-filter"].ShouldBe("send-filter");
                ah["x-send-message-filter"].ShouldBe("send-message-filter");

                bh.ShouldContainKey("x-send-filter");
                bh.ShouldContainKey("x-send-message-filter");

                // those fails, as while they DO have ",has-consume-context" they don't have access to SomePayload
                bh["x-send-filter"].ShouldBe("send-filter,has-consume-context,has-some-payload:hello");
                bh["x-send-message-filter"].ShouldBe("send-message-filter,has-consume-context,has-some-payload:hello");
            }
        }
        public void SimpleExample1b()
        {
            _mapper.AddInitialDistributionAndContinuation(0);
            _mapper.ProbabilisticSplit(0, 1, 2);
            _mapper.NonDeterministicSplit(1, 3, 4);

            var existingDistributions = new Dictionary <int, bool>();
            var entries = CountEntriesAndAddDistributionsToMap(0, existingDistributions);

            entries.ShouldBe(0);

            entries = CountEntriesAndAddDistributionsToMap(1, existingDistributions);
            entries.ShouldBe(0);

            entries = CountEntriesAndAddDistributionsToMap(2, existingDistributions);
            entries.ShouldBe(2);

            entries = CountEntriesAndAddDistributionsToMap(3, existingDistributions);
            entries.ShouldBe(1);

            entries = CountEntriesAndAddDistributionsToMap(4, existingDistributions);
            entries.ShouldBe(1);

            existingDistributions.Count.ShouldBe(2);
            existingDistributions.ShouldContainKey(0);
            existingDistributions.ShouldContainKey(1);
        }
Ejemplo n.º 5
0
        public async Task Should_contain_the_same_payloads()
        {
            EndpointConvention.Map <B>(InputQueueAddress);

            var sendObserver = new TestSendObserver(TimeSpan.FromSeconds(3));

            using (Bus.ConnectSendObserver(sendObserver))
            {
                await InputQueueSendEndpoint.Send(new A());

                ISentMessage <A> a = sendObserver.Messages.Select <A>().FirstOrDefault();
                ISentMessage <B> b = sendObserver.Messages.Select <B>().FirstOrDefault();

                a.ShouldNotBeNull();
                b.ShouldNotBeNull();

                Dictionary <string, object> ah = a.Context.Headers.GetAll().ToDictionary(x => x.Key, x => x.Value);
                Dictionary <string, object> bh = b.Context.Headers.GetAll().ToDictionary(x => x.Key, x => x.Value);

                ah.ShouldContainKey("x-send-filter");
                ah.ShouldContainKey("x-send-message-filter");
                ah["x-send-filter"].ShouldBe("send-filter");
                ah["x-send-message-filter"].ShouldBe("send-message-filter");

                bh.ShouldContainKey("x-send-filter");
                bh.ShouldContainKey("x-send-message-filter");

                // those fails, as while they DO have ",has-consume-context" they don't have access to SomePayload
                bh["x-send-filter"].ShouldBe("send-filter,has-consume-context,has-some-payload:hello");
                bh["x-send-message-filter"].ShouldBe("send-message-filter,has-consume-context,has-some-payload:hello");
            }
        }
Ejemplo n.º 6
0
    public void AndInterrogationShowsPublishersHaveBeenSet()
    {
        dynamic response = SystemUnderTest.Interrogate();

        Dictionary <string, InterrogationResult> publishedTypes = response.Data.PublishedMessageTypes;

        publishedTypes.ShouldContainKey(nameof(OrderAccepted));
        publishedTypes.ShouldContainKey(nameof(OrderRejected));
    }
Ejemplo n.º 7
0
        public void Button1Click_Always_CreatesConnectionAndSetsValues()
        {
            // Arrange
            var passedValues = new Dictionary <string, string>();

            var shimEconfig = new Shimeconfig(_testEntity);

            shimEconfig.setValSqlConnectionStringString =
                (connection, itemKey, itemValue) => passedValues.Add(itemKey, itemValue);

            ShimCoreFunctions.getConnectionStringGuid = _ => ConnectionString;

            SetupPageControls();
            ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = code => code();

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

            // Assert
            _adoShims.ShouldSatisfyAllConditions(
                () => _adoShims.IsConnectionCreated(ConnectionString).ShouldBeTrue(),
                () => _adoShims.IsConnectionOpened(ConnectionString).ShouldBeTrue(),
                () => _adoShims.IsConnectionDisposed(ConnectionString).ShouldBeTrue(),
                () => passedValues.ShouldContainKey("AssignedToField"),
                () => passedValues.ShouldContainKey("TimesheetField"),
                () => passedValues.ShouldContainKey("TimesheetHoursField"),
                () => passedValues.ShouldContainKey("LockSynch"),
                () => passedValues.ShouldContainKey("ForceWS"),
                () => passedValues.ShouldContainKey("CrossSite"),
                () => passedValues.ShouldContainKey("DefaultURL"),
                () => passedValues.ShouldContainKey("ConnectedURLs"),
                () => passedValues.ShouldContainKey("ValidTemplates"));
        }
Ejemplo n.º 8
0
    public async Task PublishToQueueLogsShouldHaveContext()
    {
        var services = GivenJustSaying(levelOverride: LogLevel.Information)
                       .ConfigureJustSaying(
            (builder) => builder.WithLoopbackQueue <SimpleMessage>(UniqueName));

        var sp = services.BuildServiceProvider();

        var cts = new CancellationTokenSource();

        var publisher = sp.GetRequiredService <IMessagePublisher>();
        await publisher.StartAsync(cts.Token);

        var message = new SimpleMessage();
        await publisher.PublishAsync(message, cts.Token);

        var testLogger = sp.GetRequiredService <ITestLoggerSink>();

        var handleMessage = testLogger.LogEntries
                            .Single(le => le.OriginalFormat == "Published message {MessageId} of type {MessageType} to {DestinationType} '{MessageDestination}'.");

        var propertyMap = new Dictionary <string, object>(handleMessage.Properties);

        propertyMap.ShouldContainKeyAndValue("MessageId", message.Id);
        propertyMap.ShouldContainKeyAndValue("MessageType", message.GetType().FullName);
        propertyMap.ShouldContainKeyAndValue("DestinationType", "Queue");
        propertyMap.ShouldContainKey("MessageDestination");

        cts.Cancel();
    }
Ejemplo n.º 9
0
 public void ShouldContainKey_WhenTrue_ShouldNotThrow()
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("key", "value");
     dictionary.ShouldContainKey("key");
     dictionary.ShouldNotContainKey("rob");
 }
Ejemplo n.º 10
0
        public static void ShouldContainExact(this Dictionary <Guid, ResourceCollection[]> actual, Dictionary <Guid, ResourceCollection[]> expected)
        {
            actual.Count.ShouldBe(expected.Count);
            var expectedKeys = new List <Guid>(expected.Keys);

            expectedKeys.Sort();

            foreach (var guid in expectedKeys)
            {
                actual.ShouldContainKey(guid);
                var actualList   = new List <ResourceCollection>(actual[guid]);
                var expectedList = new List <ResourceCollection>(expected[guid]);

                actualList.Count.ShouldBe(expectedList.Count);
                actualList.Sort();
                expectedList.Sort();

                for (var i = 0; i < expectedList.Count; i++)
                {
                    actualList[i].Location.ShouldBe(expectedList[i].Location);
                    actualList[i].Resources.ShouldBe(expectedList[i].Resources);
                }

                actual.Remove(guid);
            }

            actual.Count.ShouldBe(0);
        }
Ejemplo n.º 11
0
        public void ChangeStatusOfProductTo(string productKey, string status)
        {
            new Pages.DataHub.MainPage(TestSetup.Driver)
            .SelectManageProduct();

            var p = FeatureContext.Current.Get <Product>(productKey);

            new Pages.DataHub.ProductManage(TestSetup.Driver)
            .FilterByGtin(p.GTIN)
            .SelectFirstItem();

            new Pages.DataHub.ProductDetails(TestSetup.Driver)
            .SelectStatus(status)
            .Save();

            void Handle <T>() where T : Pages.DataHub.Popup <T> =>
            ((T)Activator.CreateInstance(typeof(T), TestSetup.Driver)).Dismiss();

            var handlers = new Dictionary <string, Action>
            {
                { "In Use", () => Handle <Pages.DataHub.PopupStatusChangeInUse>() },
                { "Archived", () => Handle <Pages.DataHub.PopupStatusChangeArchived>() }
            };

            handlers.ShouldContainKey(status);

            handlers[status]();

            new Pages.DataHub.ProductDetails(TestSetup.Driver)
            .WaitSpinner();
        }
Ejemplo n.º 12
0
    public void AndInterrogationShowsNonDuplicatedPublishers()
    {
        dynamic response = SystemUnderTest.Interrogate();

        Dictionary <string, InterrogationResult> publishedTypes = response.Data.PublishedMessageTypes;

        publishedTypes.ShouldContainKey(nameof(Message));
    }
Ejemplo n.º 13
0
        public void ShouldContainKey_WhenTrue_ShouldNotThrow()
        {
            var dictionary = new Dictionary <string, string> {
                { "key", "value" }
            };

            dictionary.ShouldContainKey("key");
            dictionary.ShouldNotContainKey("rob");
        }
 public void ShouldContainKey()
 {
     DocExampleWriter.Document(() =>
     {
         var websters = new Dictionary<string, string>();
         websters.Add("Embiggen", "To empower or embolden.");
         websters.ShouldContainKey("Cromulent");
     }, _testOutputHelper);
 }
 public void ShouldContainKey()
 {
     DocExampleWriter.Document(() =>
     {
         var websters = new Dictionary <string, string>();
         websters.Add("Embiggen", "To empower or embolden.");
         websters.ShouldContainKey("Cromulent");
     }, _testOutputHelper);
 }
        public void WorksWithOffset()
        {
            var offset = int.MaxValue + 55L;

            _mapper.AddInitialDistributionAndContinuation(offset);
            _mapper.ProbabilisticSplit(offset + 0, offset + 1, offset + 2);
            _mapper.NonDeterministicSplit(offset + 1, offset + 3, offset + 4);
            _mapper.Clear();
            offset = 13L;
            _mapper.AddInitialDistributionAndContinuation(offset);
            _mapper.ProbabilisticSplit(offset + 0, offset + 1, offset + 2);
            _mapper.NonDeterministicSplit(offset + 1, offset + 3, offset + 4);
            _mapper.Clear();
            offset = int.MaxValue * 2L;
            _mapper.AddInitialDistributionAndContinuation(offset);
            _mapper.ProbabilisticSplit(offset + 0, offset + 1, offset + 2);
            _mapper.NonDeterministicSplit(offset + 1, offset + 3, offset + 4);
            _mapper.Clear();
            offset = int.MaxValue + 55L;
            _mapper.AddInitialDistributionAndContinuation(offset);
            _mapper.ProbabilisticSplit(offset + 0, offset + 1, offset + 2);
            _mapper.NonDeterministicSplit(offset + 1, offset + 3, offset + 4);

            var existingDistributions = new Dictionary <int, bool>();
            var entries = CountEntriesAndAddDistributionsToMap(offset + 0, existingDistributions);

            entries.ShouldBe(0);

            entries = CountEntriesAndAddDistributionsToMap(offset + 1, existingDistributions);
            entries.ShouldBe(0);

            entries = CountEntriesAndAddDistributionsToMap(offset + 2, existingDistributions);
            entries.ShouldBe(2);

            entries = CountEntriesAndAddDistributionsToMap(offset + 3, existingDistributions);
            entries.ShouldBe(1);

            entries = CountEntriesAndAddDistributionsToMap(offset + 4, existingDistributions);
            entries.ShouldBe(1);

            existingDistributions.Count.ShouldBe(2);
            existingDistributions.ShouldContainKey(0);
            existingDistributions.ShouldContainKey(1);
        }
Ejemplo n.º 17
0
        public async Task HandleMessageFromQueueLogs_ShouldHaveContext(bool handlerShouldSucceed, LogLevel level, string status, string exceptionMessage)
        {
            var handler = new InspectableHandler <SimpleMessage>()
            {
                ShouldSucceed = handlerShouldSucceed,
            };

            if (exceptionMessage != null)
            {
                handler.OnHandle = msg => throw new Exception(exceptionMessage);
            }

            var services = GivenJustSaying(levelOverride: LogLevel.Information)
                           .ConfigureJustSaying(
                (builder) => builder.WithLoopbackQueue <SimpleMessage>(UniqueName)
                .Subscriptions(sub => sub.WithDefaults(sgb =>
                                                       sgb.WithDefaultConcurrencyLimit(10))))
                           .AddSingleton <IHandlerAsync <SimpleMessage> >(handler);

            var sp = services.BuildServiceProvider();

            var cts = new CancellationTokenSource();

            var publisher = sp.GetRequiredService <IMessagePublisher>();
            await publisher.StartAsync(cts.Token);

            await sp.GetRequiredService <IMessagingBus>().StartAsync(cts.Token);

            var message = new SimpleMessage();
            await publisher.PublishAsync(message, cts.Token);

            await Patiently.AssertThatAsync(() => handler.ReceivedMessages
                                            .ShouldHaveSingleItem()
                                            .Id.ShouldBe(message.Id));

            var testLogger = sp.GetRequiredService <ITestLoggerSink>();

            await Patiently.AssertThatAsync(() =>
            {
                var handleMessage = testLogger.LogEntries
                                    .SingleOrDefault(le => le.OriginalFormat == "{Status} handling message with Id '{MessageId}' of type {MessageType} in {TimeToHandle}ms.");

                handleMessage.ShouldNotBeNull();

                handleMessage.LogLevel.ShouldBe(level);
                handleMessage.Exception?.Message.ShouldBe(exceptionMessage);

                var propertyMap = new Dictionary <string, object>(handleMessage.Properties);
                propertyMap.ShouldContainKeyAndValue("Status", status);
                propertyMap.ShouldContainKeyAndValue("MessageId", message.Id);
                propertyMap.ShouldContainKeyAndValue("MessageType", message.GetType().FullName);
                propertyMap.ShouldContainKey("TimeToHandle");
            });

            cts.Cancel();
        }
Ejemplo n.º 18
0
        public void Can_set_user()
        {
            var environment = new Dictionary <string, object>();
            var owinRequest = new OwinRequest(environment)
            {
                User = new ClaimsPrincipal()
            };

            environment.ShouldContainKey("owin.RequestUser");
        }
Ejemplo n.º 19
0
        public void SaveSettings_AddNewJob_DaoInsertLabelErrorVisibleFalse()
        {
            // Arrange
            var actualParam = new Dictionary <string, object>();

            DefaultPageInit();
            ShimPage.AllInstances.RequestGet = sender => new ShimHttpRequest()
            {
                QueryStringGet = () => new NameValueCollection()
                {
                    { UidField, null }
                }
            };

            _shimDao.ExecuteNonQuerySqlConnection = sqlConnection => true;
            _shimDao.AddParamStringObject         = (nameParam, valueParam) => actualParam.Add(nameParam, valueParam);

            var currentWeb = new ShimSPWeb()
            {
                IDGet   = () => DummyGuid,
                SiteGet = () => new ShimSPSite()
                {
                    IDGet = () => DummyGuid2
                }
            };

            // Act
            _privateObject.Invoke(SaveSettingsMethodName, currentWeb.Instance);

            // Assert
            LoadFields();

            this.ShouldSatisfyAllConditions(
                () => _actualCommand.ShouldBe(InsertTimerJobs),
                () => actualParam.ShouldContainKey($"@{TimeJobUidField}"),
                () => actualParam[$"@{TimeJobUidField}"].ShouldBeOfType <Guid>(),
                () => actualParam.ShouldContainKeyAndValue($"@{JobNameField}", DummyJobName),
                () => actualParam.ShouldContainKeyAndValue($"@{SiteGuidField}", DummyGuid2),
                () => actualParam.ShouldContainKeyAndValue($"@{WebGuidField}", DummyGuid),
                () => actualParam.ShouldContainKeyAndValue($"@{ListGuidField}", DBNull.Value),
                () => actualParam.ShouldContainKeyAndValue($"@{JobTypeField}", 7),
                () => actualParam.ShouldContainKeyAndValue($"@{EnabledField}", true),
                () => actualParam.ShouldContainKeyAndValue($"@{RunTimeField}", 1),
                () => actualParam.ShouldContainKeyAndValue($"@{ScheduleTypeField}", 2),
                () => actualParam.ShouldContainKeyAndValue($"@{DaysField}", "3"),
                () => actualParam.ShouldContainKeyAndValue($"@{JobDataField}", DummyListName),
                () => actualParam.ShouldContainKeyAndValue($"@{LastQueueCheckField}", DBNull.Value),
                () => actualParam.ShouldContainKeyAndValue($"@{ParentJobUidField}", DBNull.Value),
                () => _labelErrorSite.Visible.ShouldBeFalse());
        }
Ejemplo n.º 20
0
        public void RecordFrequencyForAllStemsOfWord()
        {
            // Arrange
            Dictionary <string, int> dictionaryInput = new Dictionary <string, int>
            {
                { "jumping", 2 },
                { "jump", 1 },
                { "jumped", 4 },
                { "jumps", 1 },
                { "run", 2 },
                { "running", 3 },
                { "runs", 1 }
            };

            // Act
            Dictionary <string, int> result = TextAnalyzer.StemWords(dictionaryInput);

            // Assert
            result.Count.ShouldBe(2);
            result.ShouldContainKey("jump");
            result.ShouldContainKey("run");
            result["jump"].ShouldBe(8);
            result["run"].ShouldBe(6);
        }
        public void ApplicationError_HttpException_CodeException()
        {
            // Arrange
            ShimHttpServerUtility.AllInstances.GetLastError = (instance) => new ShimHttpException
            {
                GetHttpCode = () => throw new Exception()
            };

            // Act
            _mvcApplication.Invoke(Application_Error_MethodName, new object[] { null, null });

            // Assert
            _mvcApplication.ShouldSatisfyAllConditions(
                () => _redirectionPath.ShouldBe(RedirectDestination + HardErrror_ErrorType),
                () => _errorMessage.ShouldBe(ErrorMessage),
                () => _applicationID.ShouldBe(1),
                () => _applicationState.ShouldContainKey(ApplicationStateErrorEntryKey));
        }
Ejemplo n.º 22
0
        public void OnPreRender_NotArchivedColumn_RegisterRestoreButton()
        {
            // Arrange
            ShimSPListItem.AllInstances.ItemGetString = (_, key) =>
            {
                switch (key)
                {
                case ProjectArchiverService.ArchivedColumn:
                    return(true);

                case "WorkspaceUrl":
                    return(string.Empty);

                default:
                    return(DummyString);
                }
            };
            ShimListCommands.GetRibbonPropsSPList = _ => new RibbonProperties
            {
                bBuildTeam  = true,
                aEPKButtons = new ArrayList {
                    "costs", "resplan"
                },
                aEPKActivex = new ArrayList()
            };

            // Act
            _privateObject.Invoke(MethodOnPreRender, new object[] { EventArgs.Empty });

            // Assert
            _registeredExtensions.ShouldNotBeNull();
            _registeredExtensions.ShouldNotBeEmpty();
            this.ShouldSatisfyAllConditions(
                () =>
            {
                _registeredExtensions.ShouldContainKey(EditActionsButton);
                var node = _registeredExtensions[EditActionsButton];
                var id   = node.Attributes["Id"];
                id.ShouldNotBeNull();
                id.Value.ShouldBe("Ribbon.ListItem.EPMLive.FavoriteStatus");
            });
        }
        public void OneDistributionWithThreeContinuations()
        {
            _mapper.AddInitialDistributionAndContinuation(0);
            _mapper.ProbabilisticSplit(0, 1, 3);

            var existingDistributions = new Dictionary <int, bool>();

            var entries = CountEntriesAndAddDistributionsToMap(1, existingDistributions);

            entries.ShouldBe(1);

            entries = CountEntriesAndAddDistributionsToMap(2, existingDistributions);
            entries.ShouldBe(1);

            entries = CountEntriesAndAddDistributionsToMap(3, existingDistributions);
            entries.ShouldBe(1);

            existingDistributions.Count.ShouldBe(1);
            existingDistributions.ShouldContainKey(0);
        }
        private static void AssertThatReturnedErrorsMatchExpected(Dictionary <string, CustomModelStateEntry> errorsToExpect, ContentResult contentResult)
        {
            var returnedErrors = JsonConvert.DeserializeObject <Dictionary <string, CustomModelStateEntry> >(contentResult.Content,
                                                                                                             new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            foreach (var returnedError in returnedErrors)
            {
                errorsToExpect.ShouldContainKey(returnedError.Key);

                var expectedEntryErrorMessages = errorsToExpect
                                                 .First(e => e.Key == returnedError.Key)
                                                 .Value
                                                 .Errors
                                                 .Select(e => e.ErrorMessage);

                foreach (var errorMessage in returnedError.Value.Errors)
                {
                    expectedEntryErrorMessages.ShouldContain(errorMessage.ToString());
                }
            }
        }
Ejemplo n.º 25
0
        public void BtnSaveClick_DisposesProperly()
        {
            using (TestCheck.OpenCloseConnections)
            {
                // Arrange
                SetupShimSecurity();
                SetupEditFields();
                SetupWebProperty();
                SetupSqlCommandAndDataReader(false);
                ShimSPUtility.RedirectStringSPRedirectFlagsHttpContext = (_1, _2, _3) => true;
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // Act
                _privateEditObject.Invoke("btnSave_Click", this, EventArgs.Empty);

                // Assert
                this.ShouldSatisfyAllConditions(
                    () => _actualParameters.ShouldContainKey("@siteid"),
                    () => _actualParameters.ShouldContainKey("@name"),
                    () => _actualParameters.ShouldContainKey("@xml"),
                    () => _actualParameters.ShouldContainKey("@newname"));
            }
        }
Ejemplo n.º 26
0
 protected override void ShouldThrowAWobbly()
 {
     _dictionary.ShouldContainKey(new MyThing());
 }
Ejemplo n.º 27
0
 protected override void ShouldThrowAWobbly()
 {
     _dictionary.ShouldContainKey(_missingGuid);
 }
Ejemplo n.º 28
0
 protected override void ShouldThrowAWobbly()
 {
     _dictionary.ShouldContainKey("bar", "Some additional context");
 }
Ejemplo n.º 29
0
 protected override void ShouldThrowAWobbly()
 {
     _dictionary.ShouldContainKey("bar");
 }
Ejemplo n.º 30
0
 private void ThenTheUserShouldBeSaved()
 {
     StoredUsers.ShouldContainKey(CurrentUser.Name.ToLower());
     StoredUsers[CurrentUser.Name.ToLower()].ShouldBe(CurrentUser);
 }
Ejemplo n.º 31
0
 private void ThenTheUserShouldBeUpdated()
 {
     StoredUsers.ShouldContainKey(UpdatedUser.Name.ToLower());
     StoredUsers[UpdatedUser.Name.ToLower()].ShouldBe(UpdatedUser);
 }
Ejemplo n.º 32
0
        public async Task should_be_able_to_query_with_multiple_list_items_and_have_include()
        {
            using var documentStore = SeparateStore(x =>
            {
                x.AutoCreateSchemaObjects = AutoCreate.All;
                x.Schema.For <TestEntity>();
                x.Schema.For <OtherTestEntity>();
            });

            await documentStore.Advanced.Clean.DeleteAllDocumentsAsync();

            var otherEntityTestId = Guid.NewGuid();

            await using (var session = documentStore.OpenSession())
            {
                var otherEntityOne   = CreateOtherTestEntity(session, otherEntityTestId, "Other one");
                var otherEntityTwo   = CreateOtherTestEntity(session, Guid.NewGuid(), "Other two");
                var otherEntityThree = CreateOtherTestEntity(session, Guid.NewGuid(), "Other three");

                session.Store(new TestEntity
                {
                    Name     = "Test",
                    OtherIds = new List <Guid>
                    {
                        otherEntityOne.Id,
                        otherEntityTwo.Id
                    }
                });

                session.Store(new TestEntity
                {
                    Name     = "Test 2",
                    OtherIds = new List <Guid>
                    {
                        otherEntityTwo.Id,
                        otherEntityThree.Id
                    }
                });

                await session.SaveChangesAsync();
            }

            await using (var session = documentStore.OpenSession())
            {
                var otherIdsQuery = new[]
                {
                    otherEntityTestId,
                    Guid.NewGuid()
                };

                var otherTestEntityLookup = new Dictionary <Guid, OtherTestEntity>();
                var entities = await session.Query <TestEntity>()
                               .Include(x => x.OtherIds, otherTestEntityLookup)
                               .Where(x => x.OtherIds.Any(id => otherIdsQuery.Contains(id)))
                               .ToListAsync();

                entities.Count.ShouldBe(1);
                entities[0].OtherIds.Count.ShouldBe(2);
                entities[0].OtherIds.ShouldContain(otherEntityTestId);

                otherTestEntityLookup.Count.ShouldBe(2);
                otherTestEntityLookup.ShouldContainKey(otherEntityTestId);
            }
        }