Beispiel #1
0
        public void TestGetRowFromEntity_WithInstances_ShouldReturnBigQueryInsertRow(BusinessTraceData trace)
        {
            //Arrange
            var traceType = trace.GetType();

            //Act
            var row = BigQueryRowAdapter.GetRowFromEntity(trace, traceType);

            //Assert
            Assert.Equal(typeof(BigQueryInsertRow), row.GetType());
            Assert.NotEmpty(row);
        }
Beispiel #2
0
        public void TestGetRowFromEntity_WithInstance_ShouldReturnBigQueryInsertRow()
        {
            //Arrange
            var timestamp = DateTime.Now;
            var trace     = new BusinessTraceData(timestamp);

            //Act
            var row = BigQueryRowAdapter.GetRowFromEntity(trace, trace.GetType());

            //Assert
            Assert.Equal(typeof(BigQueryInsertRow), row.GetType());
            Assert.NotEmpty(row);
            Assert.Equal(100, row["Id"]);
            Assert.Equal("Test title", row["Title"]);
            Assert.Equal(timestamp.ToString("s"), row["CreatedAt"]);
            Assert.Equal(true, row["IsActive"]);
            Assert.Equal("300.00", row["Amount"]);
            Assert.Collection((List <int>)row["ChildTraces"],
                              item1 => { Assert.Equal(1, item1); },
                              item2 => { Assert.Equal(2, item2); },
                              item3 => { Assert.Equal(3, item3); },
                              item4 => { Assert.Equal(4, item4); },
                              item5 => { Assert.Equal(5, item5); }
                              );
            Assert.Collection((List <string>)row["Tags"],
                              item1 => { Assert.Equal("Value1", item1); },
                              item2 => { Assert.Equal("Value2", item2); },
                              item3 => { Assert.Equal("Value3", item3); }
                              );
            Assert.Collection((List <string>)row["ModifiedAt"],
                              item1 => { Assert.Equal(timestamp.AddDays(-1).ToString("s"), item1); },
                              item2 => { Assert.Equal(timestamp.AddDays(-2).ToString("s"), item2); }
                              );
            Assert.Collection((List <string>)row["Billing"],
                              item1 => { Assert.Equal("1200.00", item1); },
                              item2 => { Assert.Equal("2400.00", item2); },
                              item3 => { Assert.Equal("4800.00", item3); },
                              item4 => { Assert.Equal("9600.00", item4); }
                              );

            Assert.Equal(typeof(BigQueryInsertRow), row["Detail"].GetType());
            Assert.NotEmpty((BigQueryInsertRow)row["Detail"]);
            Assert.Equal(1, ((BigQueryInsertRow)row["Detail"])["Id"]);
            Assert.Equal("Test Description", ((BigQueryInsertRow)row["Detail"])["Description"]);
            Assert.Equal(true, ((BigQueryInsertRow)row["Detail"])["IsSuccesful"]);
            Assert.Equal(timestamp.ToString("s"), ((BigQueryInsertRow)row["Detail"])["Timestamp"]);
            Assert.Throws <KeyNotFoundException>(() => (BigQueryInsertRow)row["PrivateDetail"]);

            Assert.Collection((List <BigQueryInsertRow>)row["History"],
                              item1 =>
            {
                Assert.Equal(0, item1["Id"]);
                Assert.Null(item1["Description"]);
                Assert.False((bool)item1["IsSuccesful"]);
                Assert.Null(item1["Timestamp"]);
            },
                              item2 =>
            {
                Assert.Equal(2, item2["Id"]);
                Assert.Null(item2["Description"]);
                Assert.False((bool)item2["IsSuccesful"]);
                Assert.Null(item2["Timestamp"]);
            },
                              item3 =>
            {
                Assert.Equal(3, item3["Id"]);
                Assert.NotNull(item3["Description"]);
                Assert.False((bool)item3["IsSuccesful"]);
                Assert.Null(item3["Timestamp"]);
            },
                              item4 =>
            {
                Assert.Equal(4, item4["Id"]);
                Assert.NotNull(item4["Description"]);
                Assert.True((bool)item4["IsSuccesful"]);
                Assert.Null(item4["Timestamp"]);
            },
                              item5 =>
            {
                Assert.Equal(5, item5["Id"]);
                Assert.NotNull(item5["Description"]);
                Assert.False((bool)item5["IsSuccesful"]);
                Assert.Equal(timestamp.ToString("s"), item5["Timestamp"]);
            },
                              item6 =>
            {
                Assert.Equal(6, item6["Id"]);
                Assert.NotNull(item6["Description"]);
                Assert.False((bool)item6["IsSuccesful"]);
                Assert.Equal(timestamp.ToString("s"), item6["Timestamp"]);
                Assert.Throws <KeyNotFoundException>(() => item6["UpdatedById"]);
            }
                              );
        }