Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface IMath
- {
- int ReturnAbsValue(double i);
- int ReturnFloorValue(double i);
- }
- using System;
- public class MockMatchClass:IMath
- {
- public MockMatchClass()
- {
- Value = 0.0;
- }
- public double Value { get; set; }
- public int ReturnAbsValue(double i)
- {
- this.Value = Math.Abs(i);
- return (int)this.Value;
- }
- public int ReturnFloorValue(double i)
- {
- this.Value = Math.Floor(i);
- return (int)this.Value;
- }
- }
- using System;
- using Moq;
- using NUnit.Framework;
- public class HackTests
- {
- public Mock<MockMatchClass> mockMatchClass;
- [SetUp]
- public void Create_Mock_Math_Object()
- {
- mockMatchClass=new Mock<MockMatchClass>();
- }
- [TestCase(-5.55)]
- [TestCase(66.11)]
- public void Get_The_Abs_Value(double num)
- {
- MockMatchClass absClass = mockMatchClass.Object;
- int someAbsResult = absClass.ReturnAbsValue(num);
- int fixedAbsValue=(int)Math.Abs(num);
- Assert.That(someAbsResult ==fixedAbsValue);
- }
- [TestCase(4.55)]
- [TestCase(99.12)]
- public void Get_The_Floor_Value(double num)
- {
- MockMatchClass floorValuesClass = mockMatchClass.Object;
- int someFloorResult = floorValuesClass.ReturnAbsValue(num);
- int fixedFloorValue = (int)Math.Floor(num);
- Assert.That(someFloorResult==fixedFloorValue);
- }
- }
Add Comment
Please, Sign In to add comment