public void SeeIfProperty_1_Called_Isolated() { //Cpntrolling the behavior //Skip over some proper method //Isolate framework does //The Isolate ThirdParty code //Isolate our code that wanna test //The ThirdParty object that we have no control //we testing wether our code called the aprorprieted function that they suposed calls //and is that we are using mocking for //we can call more then one functions //could called more then one functions per once var myMock = MockRepository.GenerateMock <IRealComplexyApi>(); MyClassToTest myClass = new MyClassToTest(myMock); myMock.Expect(m => m.CallMe1()); myClass.DoSomethingReallyImportant("1"); //Assertions for Mocking myMock.VerifyAllExpectations(); //Mocks vs Stub //Stub insurance the tests goes smudly and we verify we do assertions against ours class under tests //with the Mocks is different, we do assertions on the mock itself to verify did ours class did interactions //that we expect to do hands to sort off interaction testing tittle we gave to this type of test }
public void TestMethod2() { // // TODO: Add test logic here // MyClassToTest tstClss = new MyClassToTest("a","b"); Assert.AreEqual("b b",tstClss.OneTwo()); }
public void SeeIfProperty_1_Called() { //Cpntrolling the behavior var myMock = MockRepository.GenerateMock <IRealComplexyApi>(); MyClassToTest myClass = new MyClassToTest(myMock); myMock.Expect(m => m.CallMe1()); myClass.DoSomethingReallyImportant("1"); myMock.VerifyAllExpectations(); }
public void DoStuff_OutputsStuff() { //Arrange TestableConsole console = new TestableConsole(); var sut = new MyClassToTest(); //Act sut.DoStuff(); //Assert Assert.AreEqual("Stuff", console.LastWrittenLine); }
public void SeeIfProperty_1_Called_Not_Isolated() { //Controlling the behavior //Dont Skip over some proper method //Not Isolate framework (Dont skip the method) var myMock = MockRepository.GenerateMock <RealComplexyApi>(); MyClassToTest myClass = new MyClassToTest(myMock); //myMock.Expect(m => m.CallMe1()); myClass.DoSomethingReallyImportant("1"); myMock.VerifyAllExpectations(); }