コード例 #1
0
        internal static (string ResolvedString, Dictionary <string, int> ResolvedValue) Resolve(IEnumerable <Dictionary <int, Modification> > enumerable)
        {
            var list = enumerable.ToList();
            Dictionary <string, int> firstDict = list[0].Values.OrderBy(b => b.IdWithMotif).GroupBy(b => b.IdWithMotif).ToDictionary(b => b.Key, b => b.Count());

            bool equals = true;

            foreach (var dict in list)
            {
                Dictionary <string, int> okTest = dict.Values.OrderBy(b => b.IdWithMotif).GroupBy(b => b.IdWithMotif).ToDictionary(b => b.Key, b => b.Count());
                if (!firstDict.SequenceEqual(okTest))
                {
                    equals = false;
                    break;
                }
            }
            if (!equals)
            {
                var returnString = string.Join("|", list.Select(b => string.Join(" ", b.Values.Select(c => c.IdWithMotif).OrderBy(c => c))));
                returnString = GlobalVariables.CheckLengthOfOutput(returnString);
                return(returnString, null);
            }
            else
            {
                return(string.Join(" ", list[0].Values.Select(c => c.IdWithMotif).OrderBy(c => c)), firstDict);
            }
        }
コード例 #2
0
        public void CheckNetworkTopologyStrategyKeyspace()
        {
            ITestCluster             testCluster   = TestClusterManager.GetNonShareableTestCluster(DefaultNodeCount);
            var                      session       = testCluster.Session;
            string                   keyspaceName  = TestUtils.GetUniqueKeyspaceName();
            bool                     durableWrites = Randomm.Instance.NextBoolean();
            Dictionary <string, int> datacentersReplicationFactors = null;

            string strategyClass    = ReplicationStrategies.NetworkTopologyStrategy;
            int    dataCentersCount = Randomm.Instance.Next(1, 11);

            datacentersReplicationFactors = new Dictionary <string, int>((int)dataCentersCount);
            for (int i = 0; i < dataCentersCount; i++)
            {
                datacentersReplicationFactors.Add("dc" + i, Randomm.Instance.Next(1, 21));
            }
            session.CreateKeyspace(keyspaceName,
                                   ReplicationStrategies.CreateNetworkTopologyStrategyReplicationProperty(
                                       datacentersReplicationFactors), durableWrites);

            KeyspaceMetadata ksmd = testCluster.Cluster.Metadata.GetKeyspace(keyspaceName);

            Assert.AreEqual(strategyClass, ksmd.StrategyClass);
            Assert.AreEqual(durableWrites, ksmd.DurableWrites);
            if (datacentersReplicationFactors != null)
            {
                Assert.True(datacentersReplicationFactors.SequenceEqual(ksmd.Replication));
            }
        }
コード例 #3
0
        public bool ConflictResolutionChanged(ConflictSolver other)
        {
            if (other == null)
            {
                return(true);
            }
            if (ResolveToLatest != other.ResolveToLatest)
            {
                return(true);
            }
            if (DatabaseResolverId != other.DatabaseResolverId)
            {
                return(true);
            }
            if (ResolveByCollection == null && other.ResolveByCollection == null)
            {
                return(false);
            }

            if (ResolveByCollection != null && other.ResolveByCollection != null)
            {
                return(ResolveByCollection.SequenceEqual(other.ResolveByCollection) == false);
            }
            return(true);
        }
コード例 #4
0
        public void TestBellmanFord()
        {
            var vertices = new[] { "S", "A", "B", "C", "D", "E" };
            var graph    = new[]
            {
                new BellmanFordEdge(@from: "S", to: "A", cost: 4),
                new BellmanFordEdge(@from: "S", to: "E", cost: -5),
                new BellmanFordEdge(@from: "A", to: "C", cost: 6),
                new BellmanFordEdge(@from: "B", to: "A", cost: 3),
                new BellmanFordEdge(@from: "C", to: "B", cost: -2),
                new BellmanFordEdge(@from: "D", to: "C", cost: 3),
                new BellmanFordEdge(@from: "D", to: "A", cost: 10),
                new BellmanFordEdge(@from: "E", to: "D", cost: 8),
            };

            var expected = new Dictionary <string, int>
            {
                { "S", 0 },
                { "A", 4 },
                { "B", 4 },
                { "C", 6 },
                { "D", 3 },
                { "E", -5 },
            };

            Dictionary <string, int> actual = new BellmanFordReprise().GetShortestPath(vertices, graph);

            Assert.True(expected.SequenceEqual(actual));
        }
コード例 #5
0
        public void ReportException_ExceptionIsNotNull_CallsWrapper()
        {
            Exception expectedException = new InvalidTimeZoneException("blah");
            Dictionary <string, string> expectedContextProperties = new Dictionary <string, string>
            {
                { "key 1", "value 1" },
                { "key 2", "value 2" },
            };

            Dictionary <string, string> actualContextProperties = null;

            Mock <ITelemetryClientWrapper> wrapperMock = new Mock <ITelemetryClientWrapper>(MockBehavior.Strict);

            wrapperMock.Setup(x => x.TrackException(expectedException, It.IsAny <Dictionary <string, string> >()))
            .Callback <Exception, Dictionary <string, string> >((e, d) => actualContextProperties = d);

            var aiTelemetry = new AITelemetry(wrapperMock.Object);

            foreach (KeyValuePair <string, string> pair in expectedContextProperties)
            {
                aiTelemetry.AddOrUpdateContextProperty(pair.Key, pair.Value);
            }

            aiTelemetry.ReportException(expectedException);

            Assert.IsNotNull(actualContextProperties);
            Assert.IsTrue(expectedContextProperties.SequenceEqual(actualContextProperties));

            wrapperMock.VerifyAll();
        }
コード例 #6
0
        private void OnClick(object sender, RoutedEventArgs e)
        {
            if (!_enableElements)
            {
                DialogResult = false;
                Close();
                return;
            }

            try
            {
                switch (Title)
                {
                case "Versioning Configuration (Custom Versions)":
                    CustomVersions = JsonConvert.DeserializeObject <List <FCustomVersion> >(MyAvalonEditor.Document.Text);
                    DialogResult   = !CustomVersions.SequenceEqual(_defaultCustomVersions);
                    Close();
                    break;

                case "Versioning Configuration (Options)":
                    Options      = JsonConvert.DeserializeObject <Dictionary <string, bool> >(MyAvalonEditor.Document.Text);
                    DialogResult = !Options.SequenceEqual(_defaultOptions);
                    Close();
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            catch
            {
                HeBrokeIt.Text       = "GG YOU BROKE THE FORMAT, FIX THE JSON OR CANCEL THE CHANGES!";
                HeBrokeIt.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Constants.RED));
            }
        }
コード例 #7
0
        public void UpdateMultipleNonExistingHostsAndThrowUpdateException()
        {
            _client.Id  = _noipClientId;
            _client.Key = _noipClientKey;

            Assert.IsTrue(_client.IsRegistered);

            using (ShimsContext.Create())
            {
                ShimWebClient.AllInstances.DownloadStringString = (client, s) => "host1:2\nhost2:2\n";

                var hosts = new List <Host>
                {
                    new Host("host1")
                    {
                        Address = IPAddress.Parse("127.0.0.1")
                    },
                    new Host("host2")
                    {
                        Address = IPAddress.Parse("127.0.0.1")
                    },
                };

                var ex = AssertExtensions.ExpectedException <UpdateException>(() => _client.UpdateHost(hosts));

                var expectedResults = new Dictionary <string, UpdateStatus>
                {
                    { "host1", UpdateStatus.HostNameDoesNotExist },
                    { "host2", UpdateStatus.HostNameDoesNotExist }
                };

                Assert.IsTrue(expectedResults.SequenceEqual(ex.HostStatus));
            }
        }
コード例 #8
0
    private void UpdateWidgets()
    {
        var          ind          = KMBombInfo.QUERYKEY_GET_INDICATOR;
        const string tf           = "twofactor";
        const string man          = "manufacture";
        const string day          = "day";
        const string time         = "time";
        var          newResponses = new Dictionary <string, string>
        {
            { ind, QueryWidgets <string>(ind).Select(x => x.Values).Join() },
            { tf, QueryWidgets <string>(tf).Select(x => x["twofactor_key"]).Join() },
            { man, QueryWidgets <string>(man).Select(x => x.Values).Join() },
            { day, QueryWidgets <string>(day).Select(x => x.Values).Join() },
            { time, QueryWidgets <string>(time).Select(x => x.Values).Join() }
        };

        if (!widgetsActivated)
        {
            EdgeworkPrefab.text = null;
        }
        if (widgetsActivated && (WidgetResponses.Count < 1 || !newResponses.SequenceEqual(WidgetResponses)))
        {
            WidgetResponses     = new Dictionary <string, string>(newResponses);
            EdgeworkPrefab.text = EdgeworkText;
        }
    }
コード例 #9
0
        public void MergeObjectsShallMergeDictionaries()
        {
            var dictionary1 = new Dictionary <string, int>()
            {
                { "testKey1", 1 },
                { "anotherTestKey1", 2 }
            };
            var dictionary2 = new Dictionary <string, int>()
            {
                { "testKey2", 3 },
                { "anotherTestKey2", 4 }
            };

            var expectedMergeClass = new Dictionary <string, int>()
            {
                { "testKey1", 1 },
                { "anotherTestKey1", 2 },
                { "testKey2", 3 },
                { "anotherTestKey2", 4 }
            };

            var mergedClass = ObjectMerger.ObjectMerger.MergeObjects(dictionary1, dictionary2);

            Assert.IsTrue(expectedMergeClass.SequenceEqual(mergedClass));
            Assert.IsFalse(dictionary1.SequenceEqual(mergedClass));
            Assert.IsFalse(dictionary2.SequenceEqual(mergedClass));
        }
コード例 #10
0
ファイル: Match.cs プロジェクト: amur-tiger/inform7-parser
        public bool Equals(Match other)
        {
            if (other == null)
            {
                return(false);
            }

            if (Count != other.Count)
            {
                return(false);
            }

            if (!matchNames.SequenceEqual(other.matchNames))
            {
                return(false);
            }

            for (int i = 0; i < Count; i++)
            {
                if (this[i].Count != other[i].Count)
                {
                    return(false);
                }

                for (int j = 0; j < this[i].Count; j++)
                {
                    if (!this[i][j].Equals(other[i][j]))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #11
0
ファイル: TestSteps.cs プロジェクト: Sniti/GitHubVS2013
        public void ThenIMReturnedADistinctList(string p0)
        {
            var dictionary = new Dictionary<string, int>();

            Assert.IsTrue(dictionary.SequenceEqual(this.wordCounter.GetDictionary()), "Error");
            ScenarioContext.Current.Pending();
        }
コード例 #12
0
        /// <summary>
        /// 顯示分析成分設定的對話框
        /// </summary>
        /// <param name="obj"></param>
        private void ShowCompSelectionDialog(object obj)
        {
            if (_selectedProps == null || _selectedProps.Count == 0)
            {
                System.Windows.MessageBox.Show("請至少選擇一個分析項目", "物性分析", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Asterisk);
                return;
            }

            using (View.SelectItemView2 f = new View.SelectItemView2(_selectedCompViewModel))
            {
                f.ShowDialog();
                Dictionary <int, string> tmpSelectedComps = ((SelectItemViewModel)f.DataContext).SelectedItemList;
                if (tmpSelectedComps != null && tmpSelectedComps.Count > 0)
                {
                    if (_selectedComps == null || !tmpSelectedComps.SequenceEqual(_selectedComps))
                    {
                        _selectedComps = tmpSelectedComps;
                        string lab = string.Join(",", tmpSelectedComps.Select(x => x.Value));
                        if (lab.Length > 60)
                        {
                            lab = lab.Substring(0, 57) + "...";
                        }
                        SelectedCompInfoString = lab;
                    }
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// 顯示項目設定的對話框
        /// </summary>
        /// <param name="obj"></param>
        private void ShowPropSelectionDialog(object obj)
        {
            if (CATE_NAME == null || string.IsNullOrWhiteSpace(CATE_NAME))
            {
                System.Windows.MessageBox.Show("請先指定分析儀器/方法", "物性分析", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Asterisk);
                return;
            }

            using (View.SelectItemView2 f = new View.SelectItemView2(_selectedPropViewModel))
            {
                f.ShowDialog();
                Dictionary <int, string> tmpSelectedProps = ((SelectItemViewModel)f.DataContext).SelectedItemList;
                //_selectedProps = ((SelectItemViewModel)f.DataContext).SelectedItemList;
                if (tmpSelectedProps != null && tmpSelectedProps.Count > 0)
                {
                    if (_selectedProps == null || !tmpSelectedProps.SequenceEqual(_selectedProps))
                    {
                        _selectedProps = tmpSelectedProps;
                        string lab = string.Join(",", tmpSelectedProps.Select(x => x.Value));
                        if (lab.Length > 60)
                        {
                            lab = lab.Substring(0, 57) + "...";
                        }
                        SelectedPropInfoString = lab;
                        OnPropChanged();
                    }
                }
            }
        }
コード例 #14
0
        public void getTopRequestsTest_count3()
        {
            //arrange
            int count = 3;
            Dictionary <string, int> expected = new Dictionary <string, int>();

            expected.Add("test21", 502);
            expected.Add("test31", 100);
            expected.Add("test22", 52);
            TreeNode    root        = new TreeNode(null, 0, "TestRoot");
            TreeCreator treeCreator = new TreeCreator(root);

            treeCreator.addVectorOfNodes("Test1.Test11.Test111");
            treeCreator.addVectorOfNodes("Test2.Test21.Test211");
            treeCreator.addVectorOfNodes("Test2.Test22");
            var leafs = treeCreator.getLeafs(root);

            leafs[0].Requests.Add("test11", 5);
            leafs[0].Requests.Add("test12", 10);
            leafs[0].Requests.Add("test13", 20);
            leafs[1].Requests.Add("test21", 502);
            leafs[1].Requests.Add("test22", 52);
            leafs[1].Requests.Add("test23", 12);
            leafs[2].Requests.Add("test31", 100);
            //act
            var  actual = root.GetTopRequests(count);
            bool result = expected.SequenceEqual(actual);

            //assert
            Assert.IsTrue(result);
        }
コード例 #15
0
        public void TCollection_Map_Map_Equals_Objects_Test()
        {
            var collection1 = new Dictionary <int, Dictionary <int, ExampleClass> >
            {
                [0] = new Dictionary <int, ExampleClass>
                {
                    [1] = new ExampleClass {
                        X = 1
                    },
                    [-1] = new ExampleClass {
                        X = 2
                    }
                }
            };
            var collection2 = new Dictionary <int, Dictionary <int, ExampleClass> >
            {
                [0] = new Dictionary <int, ExampleClass>
                {
                    [1] = new ExampleClass {
                        X = 1
                    },
                    [-1] = new ExampleClass {
                        X = 2
                    }
                }
            };

            Assert.IsTrue(TCollections.Equals(collection1, collection2));
            Assert.IsFalse(collection1.SequenceEqual(collection2));  // SequenceEqual() calls Equals() of the inner list instead of SequenceEqual()
        }
コード例 #16
0
        public void ToLogicAppAction_WithInputOutput_CreatesAlternative()
        {
            // Arrange
            var trackedProperties = new Dictionary <string, string>
            {
                [Guid.NewGuid().ToString()] = BogusGenerator.Random.Word()
            };

            string trackedPropertiesJson = JsonConvert.SerializeObject(trackedProperties).OrNull(BogusGenerator);

            var workflowAction = new WorkflowRunAction(
                name: BogusGenerator.Internet.DomainName(),
                startTime: BogusGenerator.Date.Past(),
                endTime: BogusGenerator.Date.Past(),
                status: GenerateStatus(),
                error: BogusGenerator.Random.Bytes(10),
                trackedProperties: trackedPropertiesJson);
            var inputs  = BogusGenerator.Random.String();
            var outputs = BogusGenerator.Random.String();

            // Act
            var actual = LogicAppConverter.ToLogicAppAction(workflowAction, inputs, outputs);

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(workflowAction.Name, actual.Name);
            Assert.Equal(workflowAction.StartTime, actual.StartTime);
            Assert.Equal(workflowAction.EndTime, actual.EndTime);
            Assert.Equal(workflowAction.Status, actual.Status.ToString());
            Assert.Equal(workflowAction.Error, actual.Error);
            Assert.Equal(inputs, actual.Inputs);
            Assert.Equal(outputs, actual.Outputs);
            Assert.True(trackedPropertiesJson == null || trackedProperties.SequenceEqual(actual.TrackedProperties));
        }
コード例 #17
0
 public bool Equals(Inventory inventory)
 {
     return
         (inventory != null &&
          data.SequenceEqual(inventory.data) &&
          slots.SequenceEqual(inventory.slots));
 }
コード例 #18
0
    public override bool Equals(Dictionary <TKey, TValue> x, Dictionary <TKey, TValue> y)
    {
        //True if both sequences of KeyValuePair items are equal
        var sequenceEqual = x.SequenceEqual(y);

        return(sequenceEqual);
    }
コード例 #19
0
        public override IndexDefinitionCompareDifferences Compare(IndexDefinitionBase other)
        {
            var otherDefinition = other as AutoMapReduceIndexDefinition;

            if (otherDefinition == null)
            {
                return(IndexDefinitionCompareDifferences.All);
            }

            if (ReferenceEquals(this, other))
            {
                return(IndexDefinitionCompareDifferences.None);
            }

            if (Collections.SequenceEqual(otherDefinition.Collections) == false || MapFields.SequenceEqual(otherDefinition.MapFields) == false)
            {
                return(IndexDefinitionCompareDifferences.Maps);
            }

            if (GroupByFields.SequenceEqual(otherDefinition.GroupByFields) == false)
            {
                return(IndexDefinitionCompareDifferences.Reduce);
            }

            return(IndexDefinitionCompareDifferences.None);
        }
コード例 #20
0
        public void Ex15Test()
        {
            string[] inputArray = { "aaa.frx",
                                    "bbb.TXT",
                                    "xyz.dbf",
                                    "abc.pdf",
                                    "aaaa.PDF",
                                    "xyz.frt",
                                    "abc.xml",
                                    "ccc.txt",
                                    "zzz.txt" };
            Dictionary <string, int> expectedResults = new Dictionary <string, int>();

            expectedResults.Add("frx", 1);
            expectedResults.Add("txt", 3);
            expectedResults.Add("dbf", 1);
            expectedResults.Add("pdf", 2);
            expectedResults.Add("frt", 1);
            expectedResults.Add("xml", 1);

            ExercisesPart1           exercises     = new ExercisesPart1();
            Dictionary <string, int> actualResults = exercises.Ex15(inputArray);

            Assert.IsTrue(actualResults.SequenceEqual(expectedResults));
        }
コード例 #21
0
        public void when_create_groups()
        {
            Dictionary <int, Dictionary <ModbusTypeData, List <Variable> > > result =
                new Dictionary <int, Dictionary <ModbusTypeData, List <Variable> > >()
            {
                { 1, new Dictionary <ModbusTypeData, List <Variable> >()
                  {
                      { ModbusTypeData.Coils, new List <Variable>()
                                {
                                    vars[1], vars[0]
                                } },
                      { ModbusTypeData.Inputs_Registers, new List <Variable>()
                                {
                                    vars[2], vars[3]
                                } }
                  } },
                { 2, new Dictionary <ModbusTypeData, List <Variable> >()
                  {
                      { ModbusTypeData.Coils, new List <Variable>()
                                 {
                                     vars[4],
                                 } },
                      { ModbusTypeData.Inputs_Registers, new List <Variable>()
                                 {
                                     vars[5], vars[6]
                                 } }
                  } }
            };

            Dictionary <int, Dictionary <ModbusTypeData, List <Variable> > > temp = FactoryGroupModbus.CreateGroups(vars);

            temp.SequenceEqual(result);
        }
コード例 #22
0
 public bool MemberwiseEquals(ICharacterProfile maybeOther)
 {
     if (!(maybeOther is HumanoidCharacterProfile other))
     {
         return(false);
     }
     if (Name != other.Name)
     {
         return(false);
     }
     if (Age != other.Age)
     {
         return(false);
     }
     if (Sex != other.Sex)
     {
         return(false);
     }
     if (PreferenceUnavailable != other.PreferenceUnavailable)
     {
         return(false);
     }
     if (!_jobPriorities.SequenceEqual(other._jobPriorities))
     {
         return(false);
     }
     if (!_antagPreferences.SequenceEqual(other._antagPreferences))
     {
         return(false);
     }
     return(Appearance.MemberwiseEquals(other.Appearance));
 }
コード例 #23
0
ファイル: TwoStringInfo.cs プロジェクト: jeanbern/Augury
 protected bool Equals(TwoStringInfo other)
 {
     return(TwoGramCount == other.TwoGramCount && N1PlusStarww == other.N1PlusStarww &&
            NwwStarCount.Equals(other.NwwStarCount) &&
            ThreeGramCounts.SequenceEqual(other.ThreeGramCounts, new KeyValuePairIntUintComparer()) &&
            MostLikelies.SequenceEqual(other.MostLikelies));
 }
コード例 #24
0
        //Assert helpers
        private void AssertPlanCount(List <IEntityDescription> descriptions,
                                     List <ICommand> actualCommands)
        {
            Dictionary <Type, long> expectedCalls = descriptions
                                                    .Select(x => new
            {
                Type  = x.Type,
                Total = x.QuantityProvider.GetTargetQuantity()
            })
                                                    .OrderBy(x => x.Type.FullName)
                                                    .ToDictionary(x => x.Type, x => x.Total);

            Dictionary <Type, long> actualCalls = actualCommands
                                                  .Where(x => x.GetType() == typeof(GenerateEntitiesCommand))
                                                  .Select(x => ((GenerateEntitiesCommand)x).EntityContext.Type)
                                                  .GroupBy(x => x)
                                                  .Select(x => new
            {
                Type  = x.Key,
                Total = x.LongCount()
            })
                                                  .OrderBy(x => x.Type.FullName)
                                                  .ToDictionary(x => x.Type, x => x.Total);

            bool   actualListEqualsExpected = expectedCalls.SequenceEqual(actualCalls);
            string expectedString           = string.Join(", ", expectedCalls.Select(x => $"{x.Key.Name}:{x.Value}"));
            string actualString             = string.Join(", ", actualCalls.Select(x => $"{x.Key.Name}:{x.Value}"));

            Assert.IsTrue(actualListEqualsExpected
                          , $"Expected plan {expectedString} does not equal actual plan {actualString}");
        }
コード例 #25
0
 /// <summary>
 /// Type safe compare
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(ConnectionString other)
 {
     if (other == null)
     {
         return(false);
     }
     return(items.SequenceEqual(other.items));
 }
コード例 #26
0
ファイル: Program.cs プロジェクト: ghantatwins/lotalot
 public bool Equals(LottoAggregate other)
 {
     if (other == null)
     {
         return(false);
     }
     return(_collections.SequenceEqual(other._collections));
 }
コード例 #27
0
        public static void Demo()
        {
            var           now = DateTimeOffset.UtcNow.DateTime.ToShortDateString();
            List <string> lA  = new List <string>()
            {
                "111", "333", "222"
            };
            List <string> lB = new List <string>()
            {
                "111", "222", "333"
            };

            var result = lA.Select(lla => lla).OrderByDescending(lla => lla).ToList();

            int[] a = { 1, 2, 3, 4 };
            int[] b = { 1, 4, 3, 2 };
            Console.WriteLine($"int SequenceEqual: {a.SequenceEqual(b)}");

            List <int> la = new List <int>()
            {
                1, 2, 3, 4
            };
            List <int> lb = new List <int>()
            {
                1, 4, 3, 2
            };

            Console.WriteLine(la.SequenceEqual(lb));



            if (ScrambledEquals(lA, lB))
            {
                Console.WriteLine($"la and lb is ScrambledEquals equal.");
            }
            if (lA.All(lB.Contains))
            {
                Console.WriteLine($"la and lb is All equal.");
            }
            if (lA.SequenceEqual(lB))
            {
                Console.WriteLine($"SequenceEqual ");
            }

            Dictionary <string, string> dA = new Dictionary <string, string>()
            {
                { "111", "value" }, { "222", "value" }, { "333", "value" }, { "444", "value" }, { "555", "value" }
            };
            Dictionary <string, string> dB = new Dictionary <string, string>()
            {
                { "111", "value" }, { "222", "value" }, { "333", "value" }, { "444", "value" }, { "555", "value" }
            };

            if (dA.SequenceEqual(dB))
            {
                Console.WriteLine($"da and db is equal.");
            }
        }
コード例 #28
0
        public void Constructor_AcceptsObjectValues(
            object input,
            Dictionary <string, object> expectedOutput
            )
        {
            HttpRouteValueDictionary routeValues = new HttpRouteValueDictionary(input);

            Assert.True(expectedOutput.SequenceEqual(routeValues));
        }
        public void Ctor_CorrectlyInitializes_AllTheProperties()
        {
            var context = new BackgroundProcessContext(_serverId, _storage.Object, _properties, _cts.Token);

            Assert.Equal(_serverId, context.ServerId);
            Assert.True(_properties.SequenceEqual(context.Properties));
            Assert.Same(_storage.Object, context.Storage);
            Assert.Equal(_cts.Token, context.CancellationToken);
        }
コード例 #30
0
 protected bool Equals(OneStringInfo other)
 {
     return(OneGramCount == other.OneGramCount &&
            N1PlusStarwStar == other.N1PlusStarwStar &&
            N1PlusStarw == other.N1PlusStarw &&
            NwStarCount.Equals(other.NwStarCount) &&
            MostLikelies.SequenceEqual(other.MostLikelies) &&
            TwoGrams.SequenceEqual(other.TwoGrams, new KeyValuePairIntTwoStringInfoComparer()));
 }
コード例 #31
0
ファイル: focusTest.cs プロジェクト: Esylus/Dvorak
        public void sortList_intoNewList_returnDictionary()
        {//Arrange Act Assert
            Dictionary <int, int> answerDictionary = new Dictionary <int, int>();

            answerDictionary.Add(4, 5);
            answerDictionary.Add(5, 10);
            answerDictionary.Add(6, 15);
            answerDictionary.Add(7, 20);


            Dictionary <int, int> testDictionary = new Dictionary <int, int>();

            Focus testFocus = new Focus();

            testFocus.recordUserResults(4, 1);
            testFocus.recordUserResults(5, 1);
            testFocus.recordUserResults(6, 1);
            testFocus.recordUserResults(7, 1);

            testFocus.recordUserResults(4, 1);
            testFocus.recordUserResults(5, 1);
            testFocus.recordUserResults(6, 1);
            testFocus.recordUserResults(7, 1);

            testFocus.recordUserResults(4, 1);
            testFocus.recordUserResults(5, 1);
            testFocus.recordUserResults(6, 1);
            testFocus.recordUserResults(7, 0);

            testFocus.recordUserResults(4, 1);
            testFocus.recordUserResults(5, 1);
            testFocus.recordUserResults(6, 0);
            testFocus.recordUserResults(7, 0);

            testFocus.recordUserResults(4, 1);
            testFocus.recordUserResults(5, 0);
            testFocus.recordUserResults(6, 0);
            testFocus.recordUserResults(7, 0);

            testFocus.createFocusList();

            var g = testFocus.FocusList.GroupBy(i => i);

            foreach (var grp in g)
            {
                testDictionary.Add(grp.Key, grp.Count());
            }

            if (testDictionary.SequenceEqual(answerDictionary))
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
コード例 #32
0
            public void ShouldReturnAReadOnlyWrapperAroundDictionary()
            {
                // Given
                var dictionary = new Dictionary<string, object> { { "key", "value" } };

                // When
                var readOnly = dictionary.AsReadOnly();

                // Then
                Assert.True(dictionary.SequenceEqual(readOnly));
            }
コード例 #33
0
ファイル: MapTypeTest.cs プロジェクト: achinn/fluentcassandra
        public void Explicit_Dictionary_Cast()
        {
            //arrange
            Dictionary<string, int> expected = new Dictionary<string, int>() {{"item1", 1}, {"item2", 2}, {"item3", 3}};

            //act
            MapType<UTF8Type, IntegerType> actualType = MapType<UTF8Type, IntegerType>.From(expected);
            CassandraObject actual = actualType;

            //assert
            Assert.True(expected.SequenceEqual(actual.GetValue<Dictionary<string, int>>()));
        }
コード例 #34
0
 public void SimpleDeserialization(Dictionary<string, string> expectedPayload, string json)
 {
     var deserialized = InvocationPayloadSerializer.Deserialize(json);
     Assert.True(expectedPayload.SequenceEqual(deserialized));
 }
コード例 #35
0
ファイル: DictionaryCodaTest.cs プロジェクト: rikkus/cadenza
        public void SequenceEqual()
        {
            var a = new Dictionary<string, string> {
                { "a", "1" },
                { "b", "2" },
            };
            var b = new Dictionary<string, string> {
                { "b", "2" },
                { "a", "1" },
            };
            Assert.IsTrue (a.SequenceEqual (b));
            b.Remove ("a");
            Assert.IsFalse (a.SequenceEqual (b));

            a.Clear ();
            b.Clear ();
            Assert.IsTrue (a.SequenceEqual (b));
        }
コード例 #36
0
        public void UpdateMultipleNonExistingHostsAndThrowUpdateException()
        {
            _client.Id = _noipClientId;
            _client.Key = _noipClientKey;

            Assert.IsTrue(_client.IsRegistered);

            using (ShimsContext.Create())
            {
                ShimWebClient.AllInstances.DownloadStringString = (client, s) => "host1:2\nhost2:2\n";

                var hosts = new List<Host>
                {
                    new Host("host1") { Address = IPAddress.Parse("127.0.0.1") },
                    new Host("host2") { Address = IPAddress.Parse("127.0.0.1") },
                };

                var ex = AssertExtensions.ExpectedException<UpdateException>(() => _client.UpdateHost(hosts));

                var expectedResults = new Dictionary<string, UpdateStatus>
                {
                    {"host1", UpdateStatus.HostNameDoesNotExist},
                    {"host2", UpdateStatus.HostNameDoesNotExist}
                };

                Assert.IsTrue(expectedResults.SequenceEqual(ex.HostStatus));
            }
        }
コード例 #37
0
        public void CheckNetworkTopologyStrategyKeyspace()
        {
            ITestCluster testCluster = TestClusterManager.GetNonShareableTestCluster(DefaultNodeCount);
            var session = testCluster.Session;
            string keyspaceName = TestUtils.GetUniqueKeyspaceName();
            bool durableWrites = Randomm.Instance.NextBoolean();
            Dictionary<string, int> datacentersReplicationFactors = null;

            string strategyClass = ReplicationStrategies.NetworkTopologyStrategy;
            int dataCentersCount = Randomm.Instance.Next(1, 11);
            datacentersReplicationFactors = new Dictionary<string, int>((int) dataCentersCount);
            for (int i = 0; i < dataCentersCount; i++)
                datacentersReplicationFactors.Add("dc" + i, Randomm.Instance.Next(1, 21));
            session.CreateKeyspace(keyspaceName,
                ReplicationStrategies.CreateNetworkTopologyStrategyReplicationProperty(
                    datacentersReplicationFactors), durableWrites);

            KeyspaceMetadata ksmd = testCluster.Cluster.Metadata.GetKeyspace(keyspaceName);
            Assert.AreEqual(strategyClass, ksmd.StrategyClass);
            Assert.AreEqual(durableWrites, ksmd.DurableWrites);
            if (datacentersReplicationFactors != null)
                Assert.True(datacentersReplicationFactors.SequenceEqual(ksmd.Replication));
        }
コード例 #38
0
ファイル: LexDBTest.cs プロジェクト: CHiiLD/DY-InventoryApp
        public void MultiplexClassUseInDb()
        {
            //Table 클래스 중복 테스트하기
            using (DbInstance db = new DbInstance("LexDBTest1.db"))
            {
                db.Map<ClassA>().Automap(i => i.UUID).WithIndex("Value", i => i.Value);
                db.Map<ClassB>().Automap(i => i.UUID).WithIndex("Value", i => i.Value);
                db.Map<ClassC>().Automap(i => i.UUID).WithIndex("Date", i => i.Date);
                db.Map<ClassD>().Automap(i => i.UUID).WithIndex("Value", i => i.Value);
                db.Map<ClassE>().Automap(i => i.UUID).WithIndex("Value", i => i.Value);
                db.Map<ClassF>().Automap(i => i.UUID).WithIndex("Value", i => i.Value);
                db.Map<Class>().Automap(i => i.UUID).WithIndex("classF", i => i.classF);
                //db.Map<Node>().Automap(i => i.UUID).WithIndex("Str", i => i.Str).WithIndex("Link", i => i.Link);
                db.Initialize();
                db.Purge();

                //테이블 추가 및 레코드 저장
                db.Save(new ClassA(1), new ClassA(2), new ClassA(3));
                ClassA[] classA = db.LoadAll<ClassA>();
                foreach (var a in classA)
                    Console.WriteLine(a.Value);

                db.Save(new ClassB("A"), new ClassB("B"), new ClassB("C"));
                ClassB[] classB = db.LoadAll<ClassB>();
                foreach (var b in classB)
                    Console.WriteLine(b.Value);

                db.Save(new ClassA(1), new ClassA(2), new ClassA(3));
                classA = db.LoadAll<ClassA>();
                foreach (var a in classA)
                    Console.WriteLine(a.Value);

                Assert.AreEqual(db.Count<ClassA>(), 6);
                Assert.AreEqual(db.Count<ClassB>(), 3);

                //테이블 삭제
                db.Purge<ClassB>();
                classB = db.LoadAll<ClassB>();

                Assert.AreEqual(db.Count<ClassB>(), 0);
                Assert.AreEqual(classB.Length, 0);
                Assert.AreEqual(db.Count<ClassA>(), 6);

                //삭제
                var classX = new ClassA(100);
                db.Save(classX);
                Assert.AreEqual(db.Count<ClassA>(), 7);
                db.Delete(classX);
                Assert.AreEqual(db.Count<ClassA>(), 6);

                //키에 의한 삭제
                db.Save(classX);
                Assert.AreEqual(db.Count<ClassA>(), 7);
                db.DeleteByKey<ClassA, string>(classX.UUID);
                Assert.AreEqual(db.Count<ClassA>(), 6);

                //키에 의한 쿼리
                db.Save(classX);
                ClassA findA = db.LoadByKey<ClassA, string>(classX.UUID);
                Assert.AreEqual(findA.UUID, classX.UUID);
                Assert.AreEqual(findA.Value, classX.Value);

                //편집
                db.Purge<ClassA>();
                for (int i = 0; i < 10; i++)
                {
                    ClassA newA = new ClassA();
                    newA.Value = i;
                    newA.UUID = classX.UUID;
                    db.Save(newA);
                }
                Assert.AreEqual(db.Count<ClassA>(), 1);
                Assert.AreEqual(db.LoadByKey<ClassA, string>(classX.UUID).Value, 9);

                //DateTime 저장 테스트
                ClassC newC = new ClassC(DateTime.Now);
                db.Save(newC);
                ClassC findC = db.LoadByKey<ClassC, string>(newC.UUID);
                Assert.AreEqual(newC.Date, findC.Date);

                //Nullable 객체 저장 테스트
                ClassD newD = new ClassD(1);
                db.Save(newD);
                ClassD findD = db.LoadByKey<ClassD, string>(newD.UUID);
                Assert.AreEqual(newD.Value, findD.Value);

                newD = new ClassD(null);
                db.Save(newD);
                findD = db.LoadByKey<ClassD, string>(newD.UUID);
                Assert.AreEqual(newD.Value, findD.Value);

                //제네릭 객체 저장 테스트
                var list = new List<string>() { "a", "b", "c" };
                ClassE newE = new ClassE(list);
                db.Save(newE);
                ClassE findE = db.LoadByKey<ClassE, string>(newE.UUID);
                Assert.AreEqual(list.SequenceEqual(findE.Value), true);

                newE.Value.Add("d");
                db.Save(newE);
                findE = db.LoadByKey<ClassE, string>(newE.UUID);
                Assert.AreEqual(newE.Value.SequenceEqual(findE.Value), true);

                //Null 반응 테스트
                findE = db.LoadByKey<ClassE, string>(null);
                Assert.AreEqual(findE, null);

                //dictionary..
                var dic = new Dictionary<string, int>() { { "a", 1 }, { "b", 2 } };
                ClassF newF = new ClassF(dic);
                db.Save(newF);
                ClassF findF = db.LoadByKey<ClassF, string>(newF.UUID);
                Assert.AreEqual(dic.SequenceEqual(findF.Value), true);

                //newF.Value = new Dictionary<string, int>(dic);
                newF.Value["a"] = 10;
                db.Save(newF);
                findF = db.LoadByKey<ClassF, string>(newF.UUID);
                Assert.AreEqual(newF.Value.SequenceEqual(findF.Value), true);

                //트리형 Node
                Node root = new Node();
                Node i1 = new Node();
                Node i2 = new Node();

                Node i11 = new Node();
                Node i12 = new Node();
                Node i111 = new Node();

                i11.Link = i111;
                i1.Link = i11;
                i1.Link = i12;
                root.Link = i1;
                root.Link = i2;

                db.Save(root);
                Node node = db.LoadByKey<Node>(root.UUID);
            }
        }
コード例 #39
0
 public void Constructor_AcceptsObjectValues(object input, Dictionary<string, object> expectedOutput)
 {
     HttpRouteValueDictionary routeValues = new HttpRouteValueDictionary(input);
     Assert.True(expectedOutput.SequenceEqual(routeValues));
 }
コード例 #40
0
 public void GetClone_Dictionary_Cloned()
 {
     var source = new Dictionary<int, string>() { { 1, "one" }, { 2, "two" } };
     var target = CloneFactory.GetClone(source);
     Assert.IsTrue(source.SequenceEqual(target));
 }