示例#1
0
        public void GetTable_DatabaseServiceReturnsTable_ReturnsTableDto()
        {
            // Arrange
            string dbName    = "testDatabase";
            Table  testTable = new Table
            {
                Name       = "testTable",
                Attributes = { new Domain.Models.Attribute {
                                   Name = "firstAttribute", Type = "someType"
                               } },
                Rows = { { 0, new Row {
                               Id = 0, Value ={ "firstValue" }
                           } } }
            };

            // Arrange - mock dbService
            this._dbServiceMock.Setup(s => s.GetTable(dbName, testTable.Name))
            .Returns(testTable);

            // Arrange - create target
            DbWcfService target = new DbWcfService(this._dbServiceMock.Object);

            // Act
            TableDto table = target.GetTable(dbName, testTable.Name);

            // Assert
            Assert.IsNotNull(table);
            Assert.AreEqual(testTable.Name, table.Name);
            Assert.AreEqual(testTable.Attributes, table.Attributes);
            Assert.AreEqual(testTable.Rows.Values, table.Rows);
        }
示例#2
0
        public void GetTable_DatabaseServiceReturnsNull_ReturnsNull()
        {
            // Arrange
            string dbName    = "testDatabase";
            string tableName = "testTable";

            // Arrange - mock dbService
            this._dbServiceMock.Setup(s => s.GetTable(dbName, tableName))
            .Returns((Table)null);

            // Arrange - create target
            DbWcfService target = new DbWcfService(this._dbServiceMock.Object);

            // Act
            TableDto table = target.GetTable(dbName, tableName);

            // Assert
            Assert.IsNull(table);
        }
示例#3
0
        public void GetTable_DatabaseServiceThrowsExceptions_ForwardsException()
        {
            // Arrange
            string dbName    = "testDatabase";
            string tableName = "testTable";

            Exception exception = new Exception();

            // Arrange - mock dbService
            this._dbServiceMock.Setup(s => s.GetTable(dbName, tableName))
            .Throws(exception);

            // Arrange - create target
            DbWcfService target = new DbWcfService(this._dbServiceMock.Object);

            // Act
            Exception ex = Assert.Throws <Exception>(() => target.GetTable(dbName, tableName));

            Assert.AreSame(exception, ex);
        }