Ejemplo n.º 1
0
        /// <summary>
        /// Executes the Unit Test
        /// </summary>
        /// <param name="logger">The logger.</param>
        public void Test(ITestLogger logger)
        {
            Logger = logger;
            var timer = new TestActionTimer(logger);

            LoadConfigurationSettingsOnce(this);
            InitializeEntityIds();
            if (EntityIdsByLogicalName != null && EntityIdsByLogicalName.Count > 0)
            {
                timer.Time(PopulateEntityReferences, "Initialization Entity Reference (ms): ");
            }
            using (var internalService = GetInternalOrganizationServiceProxy())
            {
                // ReSharper disable once AccessToDisposedClosure
                timer.Time(() => CleanupTestData(internalService, false), "Cleanup PreTestData (ms): ");

                try
                {
                    // ReSharper disable once AccessToDisposedClosure
                    timer.Time(() => AssumedEntities = AssumedEntities.Load(internalService, GetType()), "Load Assumptions (ms): ");

                    var service = GetIOrganizationService();
                    AssertCrm = new AssertCrm(service);

                    timer.Time(() => InitializeTestData(service), "Initialize TestData (ms): ");
                    timer.Time(() => Test(service), "Run Test (ms): ");
                }
                finally
                {
                    // ReSharper disable once AccessToDisposedClosure
                    timer.Time(() => CleanupTestData(internalService, true), "Cleanup PostTestData (ms): ");
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FakeIOrganizationService" /> class.
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="logger">The logger.</param>
 public FakeIOrganizationService(IOrganizationService service, ITestLogger logger)
     : base(service)
 {
     Timer = new TestActionTimer(logger);
     RedirectExecuteRequestsToOrganizationServiceRequest = true;
 }