public async Task BuildInstanceAsync_BuildersEnqueuedForInstance_AllBuildersWorked() { var descriptor = CreateDescriptor(); var mockedBuilderOne = new Mock <IDataBuilder <IData> >(); var builderOne = mockedBuilderOne.Object; var mockedBuilderTwo = new Mock <IDataBuilder <IData> >(); var builderTwo = mockedBuilderTwo.Object; var instance = new Mock <IData>().Object; TestInstance.EnqueueBuilderForInstance(descriptor, builderOne); TestInstance.EnqueueBuilderForInstance(descriptor, builderTwo); await TestInstance.BuildInstanceAsync(descriptor, instance); mockedBuilderOne.Verify(_ => _.DoWorkAsync(instance)); mockedBuilderTwo.Verify(_ => _.DoWorkAsync(instance)); }
public async Task BuildInstanceAsync_BuildersEnqueuedForCorrectAndDifferentInstance_CorrectBuildersWorked() { var descriptorOne = CreateDescriptor(); var descriptorTwo = CreateDescriptor(); var mockedBuilderOne = new Mock <IDataBuilder <IData> >(); var builderOne = mockedBuilderOne.Object; var mockedBuilderTwo = new Mock <IDataBuilder <IData> >(); var builderTwo = mockedBuilderTwo.Object; var instance = new Mock <IData>().Object; TestInstance.EnqueueBuilderForInstance(descriptorOne, builderOne); TestInstance.EnqueueBuilderForInstance(descriptorTwo, builderTwo); await TestInstance.BuildInstanceAsync(descriptorTwo, instance); mockedBuilderOne.Verify(_ => _.DoWorkAsync(instance), Times.Never); mockedBuilderTwo.Verify(_ => _.DoWorkAsync(instance)); }