public void should_Add_or_Update_Views_When_New() { var workbook = _tableauWorkbookWithViews.First(); var newViews = Builder <TableauView> .CreateListOfSize(2).Build().ToList(); foreach (var view in newViews) { view.TableauId = $"{view.TableauId}-xx"; view.Name = $"{view.Name}-xx"; view.Voided = false; view.WorkbookTableauId = workbook.TableauId; view.TableauWorkbookId = workbook.Id; _tableauViews.Add(view); } var summary = _repository.AddOrUpdateAsync(_tableauViews).Result; _repository = new TabViewRepository(_context); var updatedViews = _repository.GetAll().ToList(); var voidedViews = updatedViews.Where(x => x.Voided).ToList(); Assert.IsTrue(updatedViews.Count == 5); Assert.IsTrue(summary.Inserts == 2); Assert.IsTrue(summary.Updates == 3); Assert.IsTrue(voidedViews.Count == summary.Voids); Console.WriteLine(summary.ShowSummary()); }
public void should_Void_Views() { var toVoild = new List <TableauView> { _repository.GetAll().First(), _repository.GetAll().Last() }; _repository.Void(toVoild); _repository.Save(); _repository = new TabViewRepository(_context); var voidedList = _repository.GetAll().Where(x => x.Voided).ToList(); Assert.IsTrue(voidedList.Count == 2); Assert.IsNotEmpty(voidedList); foreach (var v in voidedList) { Console.WriteLine($"{v} Voided:{v.Voided}"); } }
public void should_Add_or_Update_Views_When_Voided() { var toRemove = _tableauViews.Last(); _tableauViews.Remove(toRemove); var summary = _repository.AddOrUpdateAsync(_tableauViews).Result; _repository = new TabViewRepository(_context); var updatedViews = _repository.GetAll().ToList(); var voidedViews = updatedViews.Where(x => x.Voided).ToList(); Assert.IsTrue(voidedViews.Count == 1); Assert.IsTrue(updatedViews.Count == 3); Assert.IsTrue(summary.Inserts == 0); Assert.IsTrue(summary.Updates == 2); Assert.IsTrue(summary.Voids == 1); Console.WriteLine(summary.ShowSummary()); }
public void should_Add_or_Update_Views_When_Update() { foreach (var w in _tableauViews) { w.TableauId = $"{w.TableauId}-s"; w.Name = $"{w.Name}-s"; w.Voided = false; } var summary = _repository.AddOrUpdateAsync(_tableauViews).Result; _repository = new TabViewRepository(_context); var updatedViews = _repository.GetAll().ToList(); var voidedViews = updatedViews.Where(x => x.Voided).ToList(); Assert.IsTrue(updatedViews.Count == 3); Assert.IsTrue(summary.Inserts == 0); Assert.IsTrue(summary.Updates == 3); Assert.IsTrue(voidedViews.Count == summary.Voids); Console.WriteLine(summary.ShowSummary()); }