public async Task CreateAsync_DataSinkAdapter_Created() { const string TestDisplayName = "TestSink"; var adapterMock = Mocks.Of<IDataSinkAdapter>().First(); var adapterFactoryMock = new Mock<IDataSinkAdapterFactory<ITestAdapterConfiguration>>(); adapterFactoryMock .Setup(f => f.CreateAsync(It.IsAny<ITestAdapterConfiguration>(), It.IsAny<IDataTransferContext>(), It.IsAny<CancellationToken>())) .Returns(() => Task.FromResult(adapterMock)); var configuration = Mocks .Of<ITestAdapterConfiguration>(c => c.Text == "Test" && c.Number == 42) .First(); var factoryAdapter = new DataSinkAdapterFactoryAdapter<ITestAdapterConfiguration>(adapterFactoryMock.Object, TestDisplayName); var adapter = await factoryAdapter.CreateAsync(configuration, DataTransferContextMock.Instance, CancellationToken.None); Assert.AreEqual(TestDisplayName, factoryAdapter.DisplayName, TestResources.InvalidDataAdapter); Assert.IsNotNull(factoryAdapter.ConfigurationType, TestResources.EmptyConfigurationType); Assert.AreEqual(typeof(ITestAdapterConfiguration), factoryAdapter.ConfigurationType, TestResources.InvalidConfigurationType); Assert.AreEqual(adapterMock, adapter, TestResources.InvalidDataAdapter); }
public async Task CreateAsync_DataSinkAdapter_Created() { const string TestDisplayName = "TestSink"; var adapterMock = Mocks.Of <IDataSinkAdapter>().First(); var adapterFactoryMock = new Mock <IDataSinkAdapterFactory <ITestAdapterConfiguration> >(); adapterFactoryMock .Setup(f => f.CreateAsync(It.IsAny <ITestAdapterConfiguration>(), It.IsAny <IDataTransferContext>())) .Returns(() => Task.FromResult(adapterMock)); var configuration = Mocks .Of <ITestAdapterConfiguration>(c => c.Text == "Test" && c.Number == 42) .First(); var factoryAdapter = new DataSinkAdapterFactoryAdapter <ITestAdapterConfiguration>(adapterFactoryMock.Object, TestDisplayName); var adapter = await factoryAdapter.CreateAsync(configuration, DataTransferContextMock.Instance); Assert.AreEqual(TestDisplayName, factoryAdapter.DisplayName, TestResources.InvalidDataAdapter); Assert.IsNotNull(factoryAdapter.ConfigurationType, TestResources.EmptyConfigurationType); Assert.AreEqual(typeof(ITestAdapterConfiguration), factoryAdapter.ConfigurationType, TestResources.InvalidConfigurationType); Assert.AreEqual(adapterMock, adapter, TestResources.InvalidDataAdapter); }