public void NonIntegralTypesreturnZero() { // Arrange var mockedSpaceProxy = new Mock<ISpaceProxy>(); var underTest = new AverageTask<TestObject, string>(o => o.StringProperty); mockedSpaceProxy.Setup(m => m.ReadMultiple<TestObject>(It.IsAny<SqlQuery<TestObject>>())) .Returns(new[] { new TestObject { StringProperty = "foo" }, new TestObject { StringProperty = "bar" } }); // Act underTest.Execute(mockedSpaceProxy.Object, null); }
public void MaxIntegersDoNotThrowDuringSum() { // Arrange var mockedSpaceProxy = new Mock<ISpaceProxy>(); var underTest = new AverageTask<TestObject, int>(o => o.IntegerProperty); mockedSpaceProxy.Setup(m => m.ReadMultiple<TestObject>(It.IsAny<SqlQuery<TestObject>>())) .Returns(new[] {new TestObject {IntegerProperty = int.MaxValue}, new TestObject {IntegerProperty = int.MaxValue }, new TestObject {IntegerProperty = int.MaxValue}}); // Act var actual = underTest.Execute(mockedSpaceProxy.Object, null); // Assert Assert.AreEqual(int.MaxValue, actual); }
public void CalculatesAverageCorrectly() { // Arrange var mockedSpaceProxy = new Mock<ISpaceProxy>(); var underTest = new AverageTask<TestObject, int>(o => o.IntegerProperty); mockedSpaceProxy.Setup(m => m.ReadMultiple<TestObject>(It.IsAny<SqlQuery<TestObject>>())) .Returns(new[] {new TestObject {IntegerProperty = 1}, new TestObject {IntegerProperty = 2}, new TestObject {IntegerProperty = 3}}); // Act var actual = underTest.Execute(mockedSpaceProxy.Object, null); // Assert Assert.AreEqual(2, actual); }