Ejemplo n.º 1
0
        public void CustomerReportShouldContainAllCustomersMissingAddresses_CachedIntegrationTest()
        {
            // by using the CacheProxy here, calls to a potentially expensive or unavailable resource can be calculated once
            // and then reused for future test runs.

            // the first time you run this test, you can use "new History()" for the history parameter instead of a filename.
            // then take the history xml from the end of the test and use that as your initialiser from then on
            var     repository = new Repository();
            History history    = Mimic.HistoryFromFile("MissingAddressReport_CallHistory.xml");
            var     cacheProxy = Mimic.Cache <IRepository>(repository, history);

            var consumer = new Consumer(cacheProxy);

            var result = consumer.GetMissingAddressesReport();

            // after using the CacheProxy, if anything has changed you can read the new serialised cache out again
            // you may want to completely recalculate the cached calls, which you can do by passing a new History instance
            // into the GetCacheProxy method

            Mimic.SaveCachedHistoryToFile(cacheProxy, "MissingAddressReport_CallHistory_out.xml");

            AssertReportMatchesExpectations(result);
        }