public void IndexerAddTest() { var compositeDictionary = new CompositeDictionary <string, string, int>(); compositeDictionary["Id", "Name"] = 1; Assert.That(compositeDictionary["Id", "Name"], Is.EqualTo(1)); }
public void PutAll(CompositeDictionary <TPrimaryKey, TSecondaryKey, TValue> compositeDictionary) { foreach (var entry in compositeDictionary.Entries) { FastPut(entry.Key, entry.Value.Key, entry.Value.Value); } RecalculateSize(); }
/// <summary> /// Puts all composite dictionary values into builded composite dictionary. /// </summary> /// <param name="compositeDictionary">Composite dictionary</param> /// <returns>Builder instance</returns> public ImmutableCompositeDictionaryBuilder <TPk, TSk, TV> PutAll(CompositeDictionary <TPk, TSk, TV> compositeDictionary) { foreach (var entry in compositeDictionary.Entries) { Put(entry.Key, entry.Value.Key, entry.Value.Value); } return(this); }
internal CompositeRootConfigurationContainer(CompositeRootHttpServerConfiguration serverConfiguration) { ServerConfiguration = serverConfiguration; rootConfigurations = new CompositeDictionary <Guid, CompositeRootConfiguration>(); RootConfigurations = new ReadOnlyCompositeDictionary <Guid, CompositeRootConfiguration>(rootConfigurations); foreach (var configuration in ServerConfiguration.rootHttpServerConfiguration.rootConfigurations.Values) { rootConfigurations.Add(configuration.Id, new CompositeRootConfiguration(configuration, this)); } }
public void IndexerSetTest() { var compositeDictionary = new CompositeDictionary <string, string, int> { { "Id", "Name", 1 } }; compositeDictionary["Id", "Name"] = 2; Assert.That(compositeDictionary["Id", "Name"], Is.EqualTo(2)); }
public void CountTest() { var compositeDictionary = new CompositeDictionary <string, string, int> { { "Id1", "Name1", 1 }, { "Id1", "Name2", 2 }, { "Id2", "Name1", 3 }, { "Id2", "Name2", 4 }, { "Id3", "Name1", 5 } }; Assert.That(compositeDictionary.Count, Is.EqualTo(5)); }
public void RemoveItemTest() { var compositeDictionary = new CompositeDictionary <string, string, int> { { "Id1", "Name1", 1 }, { "Id1", "Name2", 2 }, { "Id2", "Name1", 3 }, { "Id2", "Name2", 4 }, { "Id3", "Name1", 5 } }; var result = compositeDictionary.Remove(new KeyValuePair <CompositeKey <string, string>, int>(new CompositeKey <string, string>("Id2", "Name2"), 4)); Assert.That(result, Is.True); Assert.That(compositeDictionary.Count, Is.EqualTo(4)); Assert.That(!compositeDictionary.Contains(new KeyValuePair <CompositeKey <string, string>, int>(new CompositeKey <string, string>("Id2", "Name2"), 4))); }
public void GetByNameTest() { var compositeDictionary = new CompositeDictionary <string, string, int> { { "Id1", "Name", 1 }, { "Id2", "Name", 2 }, { "Id3", "Name1", 3 } }; var expectedValues = new List <int> { 1, 2 }; Assert.That(compositeDictionary.GetByName("Name"), Is.EqualTo(expectedValues)); }
public void EnumirableTest() { var compositeDictionary = new CompositeDictionary <string, string, int> { { "Id1", "Name1", 1 }, { "Id1", "Name2", 2 }, { "Id2", "Name1", 3 }, { "Id2", "Name2", 4 }, { "Id3", "Name1", 5 } }; var iterationsNumber = 0; foreach (var value in compositeDictionary) { iterationsNumber++; } Assert.That(iterationsNumber, Is.EqualTo(5)); }
public void SecondaryKeys_ShouldContainAll2ndKeys() { CompositeDictionary <Guid, string, Guid> dict = new CompositeDictionary <Guid, string, Guid>(); string[] secondaryKeys = { "Sledge", "Leckie", "Snaffu" }; foreach (string key2 in secondaryKeys) { dict.Add(Guid.NewGuid(), key2, Guid.NewGuid()); } dict.SecondaryKeys .Should() .Contain(secondaryKeys); }
private static void Main() { var firstUser = new UserTypeA { UserId = 1, UserName = "******" }; var secondUser = new UserTypeA { UserId = 2, UserName = "******" }; var thirdUser = new UserTypeA { UserId = 3, UserName = "******" }; var a = new CompositeKey <UserTypeA, UserTypeB>(firstUser, new UserTypeB { Level = "First", FriendlyUserTypeA = secondUser }); var b = new CompositeKey <UserTypeA, UserTypeB>(secondUser, new UserTypeB { Level = "First", FriendlyUserTypeA = firstUser }); var e = new CompositeKey <UserTypeA, UserTypeB>(firstUser, new UserTypeB { Level = "Second", FriendlyUserTypeA = thirdUser }); var c = new CompositeDictionary <UserTypeA, UserTypeB, string> { { e.Id, e.Name, "One" } }; c.Add(a.Id, a.Name, "Two"); c[b.Id, b.Name] = "Three"; c[a.Id, a.Name] = "Four"; foreach (var variable in c) { Console.WriteLine($"Id.UserName:{variable.Key.Id.UserName};{Environment.NewLine}" + $"Name.FriendlyUserTypeA.UserName: {variable.Key.Name.FriendlyUserTypeA.UserName}, Name.Level: {variable.Key.Name.Level};{Environment.NewLine}" + $"Value: {variable.Value}{Environment.NewLine}{Environment.NewLine}"); } Console.ReadKey(); }
public void PrimaryKeys_ShouldContainAll1stKeys() { CompositeDictionary <string, Guid, Guid> dict = new CompositeDictionary <string, Guid, Guid>(); string[] primaryKeys = { "Leonard", "Raj", "Sheldon", "Howard" }; foreach (string key1 in primaryKeys) { dict.Add(key1, Guid.NewGuid(), Guid.NewGuid()); } dict.PrimaryKeys .Should() .Contain(primaryKeys); }
public void ThreadsTest() { var compositeDictionary = new CompositeDictionary <string, string, int> { { "Id1", "Name1", 1 }, { "Id1", "Name2", 2 }, { "Id2", "Name1", 3 }, { "Id2", "Name2", 4 }, { "Id3", "Name1", 5 } }; var initCount = compositeDictionary.Count; Task.Run(() => compositeDictionary.Add("TId1", "TName1", 6)); Task.Run(() => compositeDictionary.Add("TId2", "TName2", 7)); Task.Run(() => compositeDictionary.Add("TId3", "TName3", 8)); Thread.Sleep(10); Assert.AreEqual(initCount + 3, compositeDictionary.Count); }
public void Count_ShouldGiveNumberOfElements() { CompositeDictionary <int, double, string> dict = new CompositeDictionary <int, double, string>(); string[] values = { "Bart", "Homer", "Marge", "Lisa", "Maggie" }; dict.Add(1, 6.1, values[0]); dict.Add(2, 0.1, values[1]); dict.Add(3, 2.0, values[2]); dict.Add(4, -2.1, values[3]); dict.Add(5, 7.01, values[4]); dict.Should() .HaveCount(values.Length); }
public void Add_ShouldAddMultipleElements() { CompositeDictionary <int, double, string> dict = new CompositeDictionary <int, double, string>(); string[] values = { "Bart", "Homer", "Marge", "Lisa", "Maggie" }; dict.Add(1, 6.1, values[0]); dict.Add(2, 0.1, values[1]); dict.Add(3, 2.0, values[2]); dict.Add(4, -2.1, values[3]); dict.Add(5, 7.01, values[4]); dict.Values .Should() .Contain(values); }
public void DuplicatesIdTest() { var compositeDictionary = new CompositeDictionary <string, string, int> { { "Id1", "Name1", 1 }, { "Id1", "Name2", 2 }, }; var initialCompositeDictionaryCount = compositeDictionary.Count; var isExceptionThrown = false; try { compositeDictionary.Add("Id1", "Name1", 3); } catch (ArgumentException e) { isExceptionThrown = true; } Assert.That(isExceptionThrown, Is.EqualTo(true), "ArgumentException didn't throw."); Assert.That(compositeDictionary.Count, Is.EqualTo(initialCompositeDictionaryCount)); }
private void Initialize(CompositeRootHttpServer server) { Server = server; sessions = new CompositeDictionary <string, CompositeRootSession>(); Sessions = new ReadOnlyCompositeDictionary <string, CompositeRootSession>(sessions); }
internal CompositeRootContainer(CompositeRootHttpServer server) { Server = server; compositeRoots = new CompositeDictionary <string, CompositeRoot>(); CompositeRoots = new ReadOnlyCompositeDictionary <string, CompositeRoot>(compositeRoots); }
public void PutAll(CompositeDictionary <TPrimaryKey, TSecondaryKey, TValue> compositeDictionary) { throw new InvalidOperationException("Operation is not supported"); }