async Task CoCServiceReturnsRightState() { var googleCloudService = new Mock <ICloudService>(); var dropboxCloudService = new Mock <ICloudService>(); googleCloudService.Setup(s => s.Upload(It.IsAny <BlobId>())).ReturnsAsync(CoCStatus.FAILURE); dropboxCloudService.Setup(s => s.Upload(It.IsAny <BlobId>())).ReturnsAsync(CoCStatus.SUCCESS); var cloudServices = new List <ICloudService> { googleCloudService.Object, dropboxCloudService.Object }; var coCService = new CoCService(cloudServices); var state = await coCService.Upload(new List <BlobId>() { new BlobId(), new BlobId() }); Assert.Equal(state, CoCStatus.FAILURE); }
private static void RegistrationRoot() { var builder = new ContainerBuilder(); builder.RegisterType <Mapper.Mapper>().As <IMapper>().SingleInstance(); builder.RegisterType <CloudOfCloudsClient>().As <ICloudOfCloudsClient>().SingleInstance(); builder.RegisterType <FileSplitter>().As <IFileSplitter>().SingleInstance(); var store = new BlobStore(); var cocService = new CoCService(new ICloudService[] { new GoogleCloudService(store), new DropboxCloudService(store) }); builder.RegisterInstance(store).As <IBlobStore>(); builder.RegisterInstance(cocService).As <ICoCService>(); container = builder.Build(); }
async Task CoCServiceCalledServices() { var googleCloudService = new Mock <ICloudService>(); var dropboxCloudService = new Mock <ICloudService>(); googleCloudService.Setup(s => s.Upload(It.IsAny <BlobId>())).ReturnsAsync(CoCStatus.SUCCESS); dropboxCloudService.Setup(s => s.Upload(It.IsAny <BlobId>())).ReturnsAsync(CoCStatus.SUCCESS); var cloudServices = new List <ICloudService> { googleCloudService.Object, dropboxCloudService.Object }; var coCService = new CoCService(cloudServices); await coCService.Upload(new List <BlobId>() { new BlobId(), new BlobId() }); googleCloudService.Verify(s => s.Upload(It.IsAny <BlobId>()), Times.AtLeastOnce); dropboxCloudService.Verify(s => s.Upload(It.IsAny <BlobId>()), Times.AtLeastOnce); }