Don't mock the Mockingbird
Let us take a look at the following code:
// don't [<Test>] let ``should first get customers from customer service and then store them to hard drive`` () = // arrange let customerService = MockRepository.GenerateMock<ICustomerService>() let fileSystem = MockRepository.GenerateMock<IFileSystem>() let cacheJob = CacheJob(customerService, fileSystem) // setup mocks customerService.Expect(fun service -> service.GetCustomers()).Return([(1, "Mikael Lundin")]) |> ignore fileSystem.Expect(fun fs -> fs.AppendLineToFile("customer.txt", "1,Mikael Lundin")) |> ignore // act cacheJob.Execute() |> ignore // assert customerService.VerifyAllExpectations() fileSystem.VerifyAllExpectations() // do // simplify the SUT or implement a vertical slice
What if we change the storage from filesystem to database? Should the test fail when implementation changes...