public void GetTableProjection_DatabaseServiceReturnsTable_ReturnsTableDto() { // Arrange string dbName = "testDatabase"; string[] attributesNames = { "firstAttribute" }; Table testTable = new Table { Name = "testTable", Attributes = { new Domain.Models.Attribute { Name = attributesNames.First(), Type = "someType" } }, Rows = { { 0, new Row { Id = 0, Value ={ "firstValue" } } } } }; // Arrange - mock dbService this._dbServiceMock.Setup(s => s.GetTableProjection(dbName, testTable.Name, attributesNames)) .Returns(testTable); // Arrange - create target DbWcfService target = new DbWcfService(this._dbServiceMock.Object); // Act TableDto table = target.GetTableProjection(dbName, testTable.Name, attributesNames); // Assert Assert.IsNotNull(testTable); Assert.AreEqual(testTable.Name, table.Name); Assert.AreEqual(testTable.Attributes, table.Attributes); Assert.AreEqual(testTable.Rows.Values, table.Rows); }
public void GetTableProjection_DatabaseServiceReturnsNull_ReturnsNull() { // Arrange string dbName = "testDatabase"; string tableName = "testTable"; string[] attributesNames = { "firstAttribute" }; // Arrange - mock dbService this._dbServiceMock.Setup(s => s.GetTableProjection(dbName, tableName, attributesNames)) .Returns((Table)null); // Arrange - create target DbWcfService target = new DbWcfService(this._dbServiceMock.Object); // Act TableDto table = target.GetTableProjection(dbName, tableName, attributesNames); // Assert Assert.IsNull(table); }
public void GetTableProjection_DatabaseServiceThrowsExceptions_ForwardsException() { // Arrange string dbName = "testDatabase"; string tableName = "testTable"; string[] attributesNames = { "firstAttribute" }; Exception exception = new Exception(); // Arrange - mock dbService this._dbServiceMock.Setup(s => s.GetTableProjection(dbName, tableName, attributesNames)) .Throws(exception); // Arrange - create target DbWcfService target = new DbWcfService(this._dbServiceMock.Object); // Act Exception ex = Assert.Throws <Exception>(() => target.GetTableProjection(dbName, tableName, attributesNames)); Assert.AreSame(exception, ex); }