public void Dynamic_Mutation()
        {
            // arrange
            var col1 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test1"
            };
            var col2 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test2"
            };

            // act
            dynamic actual = new FluentSuperColumnFamily <AsciiType, AsciiType>("Keyspace1", "Standard1");

            actual.Test1 = col1;
            actual.Test2 = col2;

            // assert
            var mutations = ((IFluentRecord)actual).MutationTracker.GetMutations();

            Assert.AreEqual(2, mutations.Count());
            Assert.AreEqual(2, mutations.Count(x => x.Type == MutationType.Added));

            var mut1 = mutations.FirstOrDefault(x => x.Column.ColumnName == "Test1");
            var mut2 = mutations.FirstOrDefault(x => x.Column.ColumnName == "Test2");

            Assert.IsNotNull(mut1);
            Assert.IsNotNull(mut2);

            Assert.AreSame(actual, mut1.Column.GetParent().ColumnFamily);
            Assert.AreSame(actual, mut2.Column.GetParent().ColumnFamily);
        }
        public void Dynamic_Mutation()
        {
            // arrange
            var col1 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test1" };
            var col2 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test2" };

            // act
            dynamic actual = new FluentSuperColumnFamily<AsciiType, AsciiType>("Keyspace1", "Standard1");
            actual.Test1 = col1;
            actual.Test2 = col2;

            // assert
            var mutations = ((IFluentRecord)actual).MutationTracker.GetMutations();

            Assert.AreEqual(2, mutations.Count());
            Assert.AreEqual(2, mutations.Count(x => x.Type == MutationType.Added));

            var mut1 = mutations.FirstOrDefault(x => x.Column.ColumnName == "Test1");
            var mut2 = mutations.FirstOrDefault(x => x.Column.ColumnName == "Test2");

            Assert.IsNotNull(mut1);
            Assert.IsNotNull(mut2);

            Assert.AreSame(actual, mut1.Column.GetParent().ColumnFamily);
            Assert.AreSame(actual, mut2.Column.GetParent().ColumnFamily);
        }
        public void Mutation()
        {
            // arrange
            var col1 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test1"
            };
            var col2 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test2"
            };

            // act
            var actual = new FluentSuperColumnFamily <AsciiType, AsciiType>("Keyspace1", "Standard1");

            actual.Columns.Add(col1);
            actual.Columns.Add(col2);

            // assert
            var mutations = actual.MutationTracker.GetMutations();

            Assert.AreEqual(2, mutations.Count());
            Assert.AreEqual(2, mutations.Count(x => x.Type == MutationType.Added));

            var mut1 = mutations.FirstOrDefault(x => x.Column.ColumnName == "Test1");
            var mut2 = mutations.FirstOrDefault(x => x.Column.ColumnName == "Test2");

            Assert.AreSame(col1, mut1.Column);
            Assert.AreSame(col2, mut2.Column);

            Assert.AreSame(actual, mut1.Column.GetParent().ColumnFamily);
            Assert.AreSame(actual, mut2.Column.GetParent().ColumnFamily);
        }
예제 #4
0
        public override FluentSuperColumnFamily <CompareWith, CompareSubcolumnWith> Execute(BaseCassandraColumnFamily columnFamily)
        {
            var result = new FluentSuperColumnFamily <CompareWith, CompareSubcolumnWith>(Key, columnFamily.FamilyName, GetColumns(columnFamily));

            columnFamily.Context.Attach(result);
            result.MutationTracker.Clear();

            return(result);
        }
        public void Path_Set()
        {
            // arrange

            // act
            var actual = new FluentSuperColumnFamily <AsciiType, AsciiType>("Keyspace1", "Standard1");

            // assert
            Assert.AreSame(actual, actual.GetPath().ColumnFamily);
        }
		public void Path_Set()
		{
			// arrange

			// act
			var actual = new FluentSuperColumnFamily<AsciiType, AsciiType>("Keyspace1", "Standard1");

			// assert
			Assert.Same(actual, actual.GetPath().ColumnFamily);
		}
예제 #7
0
		public void Implicity_Cast_To_FluentSuperColumn()
		{
			// arrange
			var expectedName = "ShouldNotBeFound";
			var expectedColumnCount = 0;
			dynamic family = new FluentSuperColumnFamily<AsciiType, AsciiType>("Test1", "SubTest1");

			// act
			FluentSuperColumn actual = family.ShouldNotBeFound;

			// assert
			Assert.Equal(expectedName, (string)actual.ColumnName);
			Assert.Equal(expectedColumnCount, actual.Columns.Count);
		}
예제 #8
0
        public void Implicity_Cast_To_FluentSuperColumn()
        {
            // arranage
            var     expectedName        = "ShouldNotBeFound";
            var     expectedColumnCount = 0;
            dynamic family = new FluentSuperColumnFamily <AsciiType, AsciiType>("Test1", "SubTest1");

            // act
            FluentSuperColumn actual = family.ShouldNotBeFound;

            // assert
            Assert.Equal(expectedName, (string)actual.ColumnName);
            Assert.Equal(expectedColumnCount, actual.Columns.Count);
        }
		public void Get_NonExistent_Column()
		{
			// arrange
			var col1 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test1" };
			var col2 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test2" };

			// act
			dynamic family = new FluentSuperColumnFamily<AsciiType, AsciiType>("Keyspace1", "Standard1");
			family.Test1 = col1;
			family.Test2 = col2;
			var actual = family.Test3;

			// assert
			Assert.IsType(typeof(FluentSuperColumn), actual);
		}
        public void Constructor_Test()
        {
            // arrange
            var col1 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test1" };
            var col2 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test2" };

            // act
            var actual = new FluentSuperColumnFamily<AsciiType, AsciiType>("Keyspace1", "Standard1");
            actual.Columns.Add(col1);
            actual.Columns.Add(col2);

            // assert
            Assert.AreEqual(2, actual.Columns.Count);
            Assert.AreSame(col1.Family, actual);
            Assert.AreSame(col2.Family, actual);
        }
예제 #11
0
        public override IEnumerable <IFluentSuperColumnFamily <CompareWith, CompareSubcolumnWith> > Execute(BaseCassandraColumnFamily columnFamily)
        {
            CassandraSession _localSession = null;

            if (CassandraSession.Current == null)
            {
                _localSession = new CassandraSession();
            }

            try
            {
                var parent = new ColumnParent {
                    Column_family = columnFamily.FamilyName
                };

                var output = CassandraSession.Current.GetClient().get_indexed_slices(
                    parent,
                    IndexClause.CreateIndexClause(),
                    SlicePredicate.CreateSlicePredicate(),
                    CassandraSession.Current.ReadConsistency
                    );

                foreach (var result in output)
                {
                    var r = new FluentSuperColumnFamily <CompareWith, CompareSubcolumnWith>(result.Key, columnFamily.FamilyName, result.Columns.Select(col => {
                        var superCol = Helper.ConvertSuperColumnToFluentSuperColumn <CompareWith, CompareSubcolumnWith>(col.Super_column);
                        columnFamily.Context.Attach(superCol);
                        superCol.MutationTracker.Clear();

                        return(superCol);
                    }));
                    columnFamily.Context.Attach(r);
                    r.MutationTracker.Clear();

                    yield return(r);
                }
            }
            finally
            {
                if (_localSession != null)
                {
                    _localSession.Dispose();
                }
            }
        }
        public void Constructor_Dynamic_Test()
        {
            // arrange
            var col1 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test1" };
            var col2 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test2" };

            // act
            dynamic actual = new FluentSuperColumnFamily<AsciiType, AsciiType>("Keyspace1", "Standard1");
            actual.Test1 = col1;
            actual.Test2 = col2;

            // assert
            Assert.AreEqual(col1, actual.Test1);
            Assert.AreEqual(col1, actual["Test1"]);
            Assert.AreEqual(col2, actual.Test2);
            Assert.AreEqual(col2, actual["Test2"]);
            Assert.AreSame(col1.Family, actual);
            Assert.AreSame(col2.Family, actual);
        }
        public void Get_NonExistent_Column()
        {
            // arrange
            var col1 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test1"
            };
            var col2 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test2"
            };

            // act
            dynamic family = new FluentSuperColumnFamily <AsciiType, AsciiType>("Keyspace1", "Standard1");

            family.Test1 = col1;
            family.Test2 = col2;
            var actual = family.Test3;

            // assert
            Assert.IsInstanceOfType(typeof(IFluentSuperColumn), actual);
        }
        public void Constructor_Test()
        {
            // arrange
            var col1 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test1"
            };
            var col2 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test2"
            };

            // act
            var actual = new FluentSuperColumnFamily <AsciiType, AsciiType>("Keyspace1", "Standard1");

            actual.Columns.Add(col1);
            actual.Columns.Add(col2);

            // assert
            Assert.AreEqual(2, actual.Columns.Count);
            Assert.AreSame(col1.Family, actual);
            Assert.AreSame(col2.Family, actual);
        }
        public void Constructor_Dynamic_Test()
        {
            // arrange
            var col1 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test1"
            };
            var col2 = new FluentSuperColumn <AsciiType, AsciiType> {
                ColumnName = "Test2"
            };

            // act
            dynamic actual = new FluentSuperColumnFamily <AsciiType, AsciiType>("Keyspace1", "Standard1");

            actual.Test1 = col1;
            actual.Test2 = col2;

            // assert
            Assert.AreEqual(col1, actual.Test1);
            Assert.AreEqual(col1, actual["Test1"]);
            Assert.AreEqual(col2, actual.Test2);
            Assert.AreEqual(col2, actual["Test2"]);
            Assert.AreSame(col1.Family, actual);
            Assert.AreSame(col2.Family, actual);
        }
        public void Mutation()
        {
            // arrange
            var col1 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test1" };
            var col2 = new FluentSuperColumn<AsciiType, AsciiType> { ColumnName = "Test2" };

            // act
            var actual = new FluentSuperColumnFamily<AsciiType, AsciiType>("Keyspace1", "Standard1");
            actual.Columns.Add(col1);
            actual.Columns.Add(col2);

            // assert
            var mutations = actual.MutationTracker.GetMutations();

            Assert.AreEqual(2, mutations.Count());
            Assert.AreEqual(2, mutations.Count(x => x.Type == MutationType.Added));

            var mut1 = mutations.FirstOrDefault(x => x.Column.ColumnName == "Test1");
            var mut2 = mutations.FirstOrDefault(x => x.Column.ColumnName == "Test2");

            Assert.AreSame(col1, mut1.Column);
            Assert.AreSame(col2, mut2.Column);

            Assert.AreSame(actual, mut1.Column.GetParent().ColumnFamily);
            Assert.AreSame(actual, mut2.Column.GetParent().ColumnFamily);
        }