public void No_Matching_Columns_Returns_Empty_List()
    {
        // Arrange
        var table = new FooTable();

        // Act
        var result = QueryF.GetColumnsFromTable <FooNone>(table);

        // Assert
        Assert.Empty(result);
    }
Esempio n. 2
0
    public void No_Matching_Columns_Returns_None_With_NoColumnsExtractedFromTableMsg()
    {
        // Arrange
        var table = new FooTable();

        // Act
        var result = Extract <FooNone> .From(table);

        // Assert
        result.AssertNone().AssertType <NoColumnsExtractedFromTableMsg>();
    }
Esempio n. 3
0
    public void With_Table_Calls_MapService_Map()
    {
        // Arrange
        var svc   = Substitute.For <IEntityMapper>();
        var table = new FooTable();

        // Act
        Map <Foo> .To(table, svc);

        // Assert
        svc.Received().Map <Foo, FooTable>(Arg.Any <FooTable>());
    }
    public void Returns_Extracted_Columns()
    {
        // Arrange
        var table = new FooTable();

        // Act
        var result = QueryF.GetColumnsFromTable <Foo>(table);

        // Assert
        Assert.Collection(result,
                          x => Assert.Equal((table.GetName(), table.FooId), (x.TblName, x.ColName)),
                          x => Assert.Equal(table.Bar0, x.ColName),
                          x => Assert.Equal(table.Bar1, x.ColName)
                          );
    }
        public Task<DataTable> __FooTable_Insert(FooTable.InsertFoo[] value)
        {
            FooTable rw = new FooTable();


            Console.WriteLine("delete");
            // first delete and then add new content
            rw.Delete();

            value.WithEach(x =>
                {
                    Console.WriteLine("insert " + new { x.delay, x.text });

                    rw.Insert(x);
                }
            );

            return __FooTable_Select();
        }
Esempio n. 6
0
    public void Returns_Extracted_Columns_Without_Duplicates()
    {
        // Arrange
        var t0 = new FooTable();
        var t1 = new FooUnwriteableTable();
        var t2 = new FooDuplicateTable();

        // Act
        var result = Extract <FooCombined> .From(t0, t1, t2);

        // Assert
        var some = result.AssertSome();

        Assert.Collection(some,
                          x => Assert.Equal((t0.GetName(), t0.FooId), (x.TblName, x.ColName)),
                          x => Assert.Equal(t0.Bar0, x.ColName),
                          x => Assert.Equal(t1.Bar2, x.ColName)
                          );
    }
    public void Returns_Writeable_Names_And_Aliases()
    {
        // Arrange
        var table   = new FooTable();
        var columns = MapF.GetColumns <FooTable, Foo>(table).UnsafeUnwrap();
        var map     = new TableMap(table, columns, GetColumnNames_Tests.Get().column);

        // Act
        var result = map.GetWriteableColumnNamesAndAliases();

        // Assert
        var(names, aliases) = result.AssertSome();
        Assert.Collection(names,
                          x => Assert.Equal(table.Bar0, x),
                          x => Assert.Equal(table.Bar1, x)
                          );
        Assert.Collection(aliases,
                          x => Assert.Equal(nameof(table.Bar0), x),
                          x => Assert.Equal(nameof(table.Bar1), x)
                          );
    }
        // called by FooTableDesigner_Load
        public Task<DataTable> __FooTable_Select()
        {
            var n = new ScriptedNotificationsV2ScriptedNotifications();

            #region auto reset and reinit?
            if (n.Count() == 0)
            {
                ScriptedNotificationsV2.GetDataSet().Tables[0].Rows.AsEnumerable().WithEach(
                    x => n.Insert(x)
                );
            }
            #endregion

            // why cannot we do a direct AsDataTable ?
            return n.AsEnumerable().AsDataTable().AsResult();


#if V1
            var ro = ScriptedNotifications.GetDataTable();
            var rw = new FooTable().Select();

            var merge = new DataTable();



            // X:\jsc.svn\examples\java\JVMCLRDataTableMerge\JVMCLRDataTableMerge\Program.cs
            Console.WriteLine("before Merge ro");
            merge.Merge(ro);

            if (rw.Rows.Count > 0)
            {
                Console.WriteLine("before Merge rw");


                // Additional information: <target>.delay and <source>.delay have conflicting properties: DataType property mismatch.

                merge.Merge(rw);
            }

            // merge with ro data

            var columnNames = merge.Columns.AsEnumerable().Select(k => k.ColumnName).ToArray();

            var distinct = merge.DefaultView.ToTable(
                distinct: true,
                columnNames: columnNames
            );


            //            ToTable: { c = delay, value = 500 }
            //ToTable: { c = delay, xvalue = 500 }
            //ToTable: { c = text, value = howdy! }
            //ToTable: { c = text, xvalue = howdy! }
            //ToTable: { c = delay, value = 5000 }
            //ToTable: { c = delay, xvalue = 5000 }
            //ToTable: { c = text, value = how can we help you? }
            //ToTable: { c = text, xvalue = how can we help you? }
            //ToTable: { c = delay, value = 25000 }
            //ToTable: { c = delay, xvalue = 25000 }
            //ToTable: { c = text, value = do you like our site? }
            //ToTable: { c = text, xvalue = do you like our site? }
            //__FooTable_Select
            //{ ColumnName = delay, value =  }
            //{ ColumnName = text, value =  }
            //{ ColumnName = delay, value =  }
            //{ ColumnName = text, value =  }
            //{ ColumnName = delay, value =  }
            //{ ColumnName = text, value =  }

            //var xml = ScriptCoreLib.Library.StringConversionsForDataTable.ConvertToString(
            //    distinct
            //);

            //Console.WriteLine(new { xml });

            return distinct.ToTaskResult();
#endif

        }