Example #1
0
        public void ThenIMReturnedADistinctList(string p0)
        {
            var dictionary = new Dictionary<string, int>();

            Assert.IsTrue(dictionary.SequenceEqual(this.wordCounter.GetDictionary()), "Error");
            ScenarioContext.Current.Pending();
        }
            public void ShouldReturnAReadOnlyWrapperAroundDictionary()
            {
                // Given
                var dictionary = new Dictionary<string, object> { { "key", "value" } };

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

                // Then
                Assert.True(dictionary.SequenceEqual(readOnly));
            }
Example #3
0
        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>>()));
        }
Example #4
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));
        }
Example #5
0
        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);
            }
        }
 public void SimpleDeserialization(Dictionary<string, string> expectedPayload, string json)
 {
     var deserialized = InvocationPayloadSerializer.Deserialize(json);
     Assert.True(expectedPayload.SequenceEqual(deserialized));
 }
 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));
 }
 public void Constructor_AcceptsObjectValues(object input, Dictionary<string, object> expectedOutput)
 {
     HttpRouteValueDictionary routeValues = new HttpRouteValueDictionary(input);
     Assert.True(expectedOutput.SequenceEqual(routeValues));
 }
Example #9
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));
            }
        }
Example #10
0
        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));
        }