public async Task TestGetOrAddAsync() { var dict = new Dictionary<string, string>(); await dict.GetOrAddAsync("x", () => Task.FromResult("a")); await dict.GetOrAddAsync("x", () => Task.FromResult("b")); dict.Should().Equal(new Dictionary<string, string> {["x"] = "a"}); }
public void TestGetOrAdd() { var dict = new Dictionary<string, string>(); dict.GetOrAdd("x", () => "a"); dict.GetOrAdd("x", () => { throw new Exception("Should not be reached."); }); dict.Should().Equal(new Dictionary<string, string> {["x"] = "a"}); }
public void Test() { var transf = _ISession.AllAlbums.Select(all => AlbumDescriptor.CopyAlbum(all as Album, false)); transf.Count().Should().Be(5); foreach (TrackDescriptor ial in transf.SelectMany(al => al.TrackDescriptors)) { DataExchanger<TrackDescriptor> det = new DataExchanger<TrackDescriptor>(ial); Dictionary<string, object> res = new Dictionary<string, object>(); det.Describe(DataExportImportType.WindowsPhone, res.ToObserver()); res.Should().ContainKey("Artist"); res.Should().ContainKey("Album"); res.Should().ContainKey("Genre"); res.Should().ContainKey("Path"); res.Should().ContainKey("Name"); } }
public void Behave_ShouldConsumeSectionFromProvider() { var expectedConfiguration = new KeyValuePair<string, string>("AnyKey", "AnyValue"); var configuration = new Dictionary<string, string>(); var configurationSection = ExtensionConfigurationSectionHelper.CreateSection(expectedConfiguration); this.sectionProvider.Setup(p => p.GetSection(It.IsAny<string>())).Returns(configurationSection); this.consumer.Setup(c => c.Configuration).Returns(configuration); this.testee.Behave(this.extensions); configuration.Should().Contain(expectedConfiguration); }
public void ItShouldCreateTheFollower_GivenWasMissing() { //g var messages = new List<Message>(); var userToFollowed = new Dictionary<string, List<string>>(); var command = new FollowCommand("Charlie", "Alice"); //w command.ExecuteUsing(messages, userToFollowed); //t userToFollowed.Should().ContainKey("Charlie"); userToFollowed["Charlie"].Should().Contain("Alice"); }
public async Task TestGetOrAddAsyncRace() { var mock1 = new Mock(); var dict = new Dictionary<string, Mock> {["x"] = mock1}; var mock2 = new Mock(); var delayedSource = new TaskCompletionSource<Mock>(); var task = dict.GetOrAddAsync("x", () => delayedSource.Task); delayedSource.SetResult(mock2); await task; dict.Should().Equal(new Dictionary<string, Mock> {["x"] = mock1}); mock1.IsDisposed.Should().BeFalse(); mock2.IsDisposed.Should().BeFalse(); }
public void ToQueryStringParameters_Empty_ReturnsEmpty () { // arrange // act var result = new Dictionary<string, object> ().ToQueryStringParameters (); // assert result.Should ().BeEmpty (); }
public void FindOrAddShouldCreateNewAndAddIt() { var testSubject = new Dictionary<string, string>(); testSubject.FindOrAdd("foo", () => "bar").Should().Be("bar"); testSubject.Should().Contain(new KeyValuePair<string, string>("foo", "bar")); }
private void CheckViewParameters(Func<IView, IView> setupView, Dictionary<string, string> expectedParameters) { var collectedParameters = new Dictionary<string, string>(); var requestedPaths = new List<string>(); var locator = CreateParameterValidatingLocator(collectedParameters, requestedPaths); IView view = new CouchbaseView(new Mock<IMemcachedClient>().Object, locator, "doc", "index"); setupView(view).ToList(); collectedParameters.Should().Equal(expectedParameters); }