public async Task AddOrUpdateEntitiesWithNullParameterAsync() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; IEnumerable <Country> result = null; // Act try { result = await context.AddOrUpdateAsync((IEnumerable <Country>) null, CancellationToken.None); } catch (ArgumentNullException) { } // Assert Assert.Null(result); mock.Verify(executor => executor.ExecuteBatches(It.IsAny <IEnumerable <Country> >(), It.IsAny <Func <ITableEntity, TableOperation> >()), Times.Never()); }
public void RemoveEmptyCollection() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; var countries = new List <Country>(); // Act context.Remove(countries); }
public void RemoveEntitiesWithNullParameter() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; // Act Assert.Throws <ArgumentNullException>(() => context.Remove((IList <Country>)null)); // Assert mock.Verify(executor => executor.ExecuteBatches(It.IsAny <IList <Country> >(), It.IsAny <Func <ITableEntity, TableOperation> >()), Times.Never()); }
public async Task RemoveEntitiesAsync() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; IList <Country> countries = ObjectsFactory.GetCountries(); // Act await context.RemoveAsync(countries); // Assert mock.Verify(executor => executor.ExecuteBatchesWithoutResultAsync(countries, TableOperation.Delete, It.IsAny <CancellationToken>())); }
public void RemoveEntities() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; IList <Country> countries = ObjectsFactory.GetCountries(); // Act context.Remove(countries); // Assert mock.Verify(executor => executor.ExecuteBatchesWithoutResult(countries, TableOperation.Delete), Times.Once()); }
public void AddOrUpdateEmptyCollection() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; var countries = new List <Country>(); // Act var result = context.AddOrUpdate(countries); // Assert Assert.NotNull(result); Assert.Equal(countries, result); }
public void AddOrUpdateEntitiesWithNullParameter() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; IEnumerable <Country> result = null; // Act Assert.Throws <ArgumentNullException>(() => { result = context.AddOrUpdate((IEnumerable <Country>)null); }); // Assert Assert.Null(result); mock.Verify(executor => executor.ExecuteBatches(It.IsAny <IEnumerable <Country> >(), It.IsAny <Func <ITableEntity, TableOperation> >()), Times.Never()); }
public async Task AddOrUpdateEntitiesAsync() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; var countries = ObjectsFactory.GetCountries(); // Act var result = await context.AddOrUpdateAsync(countries); // Assert Assert.NotNull(result); mock.Verify(executor => executor.ExecuteBatchesAsync(countries, TableOperation.InsertOrReplace, It.IsAny <CancellationToken>())); Assert.Equal(countries, result); }
public void AddOrUpdateEntities() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; var countries = ObjectsFactory.GetCountries(); // Act var result = context.AddOrUpdate(countries); // Assert Assert.NotNull(result); mock.Verify(executor => executor.ExecuteBatches(countries, TableOperation.InsertOrReplace), Times.Once()); Assert.Equal(countries, result); }
public async Task AddEntityAsync() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; Country country = ObjectsFactory.GetCountry(); // Act Country result = await context.AddAsync(country); // Assert Assert.NotNull(result); mock.Verify(executor => executor.ExecuteAsync(country, TableOperation.Insert, It.IsAny <CancellationToken>())); Assert.Equal(country, result); }
public void AddEntity() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; Country country = ObjectsFactory.GetCountry(); // Act Country result = context.Add(country); // Assert Assert.NotNull(result); mock.Verify(executor => executor.Execute(country, TableOperation.Insert), Times.Once()); Assert.Equal(country, result); }
public void AddEntity_FluentMapping() { // Arrange Mock <ITableRequestExecutor <Address> > mock = MocksFactory.GetQueryExecutorMock <Address>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Address>(tableClient) { RequestExecutor = mock.Object }; Address model = ObjectsFactory.GetAddress(); // Act Address result = context.Add(model); // Assert Assert.NotNull(result); mock.Verify(executor => executor.Execute(model, TableOperation.Insert), Times.Once()); Assert.Equal(model, result); }
public async Task RemoveEntityWithNullParameterAsync() { // Arrange Mock <ITableRequestExecutor <Country> > mock = MocksFactory.GetQueryExecutorMock <Country>(); CloudTableClient tableClient = ObjectsFactory.GetCloudTableClient(); var context = new TableSet <Country>(tableClient) { RequestExecutor = mock.Object }; // Act try { await context.RemoveAsync((Country)null, CancellationToken.None); } catch (ArgumentNullException) { } // Assert mock.Verify(executor => executor.Execute(It.IsAny <Country>(), It.IsAny <Func <ITableEntity, TableOperation> >()), Times.Never()); }