public void ドキュメントを新規に作成しドキュメントの作成イベントが発生する() { var sut = new Document(new DocumentPath("test.txt"), "text/plain", InMemoryData.Create("storagekey1", Stream("ABCD"))); Assert.AreEqual(1, sut.DomainEvents.Count); Assert.IsTrue(sut.DomainEvents.First() is DocumentCreatedEvent); }
public void Should_Not_Add_Bike() { var inMemoryRepository = new InMemoryData <Vehicle>(_logger.Object); var result = inMemoryRepository.Add(null); Assert.False(result != null, "Test Add bike failed for failure case"); }
public void Should_Not_Find_Vehicle() { var inMemoryRepository = new InMemoryData <Vehicle>(_logger.Object); var result = inMemoryRepository.Find(new Guid()); Assert.Equal(null, result); }
public void TestGeneratedCsv() { // TODO: uncomment one of the following two lines depending on whether you're generating numbers with or without padding. var expected = this.GetPlaces("expectedWithoutPadding.csv"); //var expected = this.GetPlaces("expectedWithPadding.csv"); //TODO: invoke your code here to generate the "actual.csv" file InMemoryData dataTree = new InMemoryData( new CSVFileGenerator(), new CustomConfiguration(), new TreeBuildService() ); dataTree.GenerateFile(); var actual = this.GetPlaces(Environment.CurrentDirectory + "\\actual.csv"); // Feel free to modify the checks to add additional logging or assertions to assist troubleshooting Assert.AreEqual(expected.Count, actual.Count); foreach (var expectedKey in expected.Keys) { var expectedPlace = expected[expectedKey]; var actualPlace = actual[expectedKey]; Assert.AreEqual(expectedPlace.PublicId.ToLower(), actualPlace.PublicId.ToLower()); Assert.AreEqual(expectedPlace.PublicParentId.ToLower(), actualPlace.PublicParentId.ToLower()); Assert.AreEqual(expectedPlace.Type.ToLower(), actualPlace.Type.ToLower()); } }
public void Should_Not_GetAll_Vehicle() { var inMemoryRepository = new InMemoryData <Vehicle>(_logger.Object); var result = inMemoryRepository.GetAll(); Assert.True(result != null, " Test GetAll failed for null check in failure case"); Assert.False(result.Count > 0, "Test GetAll vehicle failed for failure case for items count"); }
public void Should__Not_Edit_Vehicle() { var inMemoryRepository = new InMemoryData <Vehicle>(_logger.Object); var result = inMemoryRepository.Edit(new Guid(carid), GetCar()); Assert.False(result, "Test Edit failed for failure case"); }
public void AddItemTest() { InMemoryData data = new InMemoryData(); data.AddItemsToCart('A', 5); var qty = data.GetAllItemsFromCart().FirstOrDefault(i => i.SKUId == 'A').Quantity; Assert.Equal(5, qty); }
public ActionResult Index() { var loginVm = new LoginVm(); loginVm.StudentName = "*****@*****.**"; //This could be read form database loginVm.Quizzes.AddRange(BuildQuizVm(InMemoryData.GetQuizData())); return(View(loginVm)); }
public void Should_Edit_Vehicle() { var inMemoryRepository = new InMemoryData <Vehicle>(_logger.Object); inMemoryRepository.Add(GetCar()); var result = inMemoryRepository.Edit(new Guid(carid), GetCar()); Assert.True(result, "Test Edit failed for success case"); }
public void ドキュメントを移動した場合ドキュメントの移動イベントが発生する() { var sut = new Document(new DocumentPath("test.txt"), "text/plain", InMemoryData.Create("storagekey1", Stream("ABCD"))); sut.ClearDomainEvents(); sut.MoveTo(new DocumentPath("test2.txt")); Assert.AreEqual(1, sut.DomainEvents.Count); Assert.IsTrue(sut.DomainEvents.First() is DocumentMovedEvent); }
public void Should_Add_Bike() { var inMemoryRepository = new InMemoryData <Vehicle>(_logger.Object); var bike = GetBike(); var result = inMemoryRepository.Add(bike); Assert.True(result != null, "Test Add bike failed for success case"); Assert.True(result.GetType() == typeof(Bike), "Test Add bike failed for type check success case"); }
public void Should_Add_Car() { var inMemoryRepository = new InMemoryData <Vehicle>(_logger.Object); var car = GetCar(); var result = inMemoryRepository.Add(car); Assert.True(result != null, "Test Add car failed for success case"); Assert.True(result.GetType() == typeof(Car), "Test Add car failed for type check success case"); }
public ActionResult Index(LoginVm loginVm) { if (ModelState.IsValid) { var examVm = new UserSelection(loginVm.QuizId, loginVm.StudentName); return(RedirectToAction("Exam", examVm)); } loginVm.Quizzes.AddRange(BuildQuizVm(InMemoryData.GetQuizData())); return(View(loginVm)); }
public void Test1() { data = new InMemoryData(); data.AddItemsToCart('A', 1); data.AddItemsToCart('B', 1); data.AddItemsToCart('C', 1); int result = data.CalculateCheckOutPrice(); Assert.Equal(100, result); }
public static Document Create(string path, string textContent) { var now = new DateTime(2018, 1, 1, 0, 0, 0, DateTimeKind.Utc); return(new Document(new DocumentPath(path), "text/plain", InMemoryData.Create(path, Encoding.UTF8.GetBytes(textContent)), now, now)); }
public void Should_GetAll_Vehicle() { var inMemoryRepository = new InMemoryData <Vehicle>(_logger.Object); inMemoryRepository.Add(GetCar()); var result = inMemoryRepository.GetAll(); Assert.True(result != null, "Test GetAll failed for null check in success case"); Assert.True(result.Count > 0, "Test GetAll vehicle failed for success case for items count"); }
public void Test2() { data = new InMemoryData(); data.AddItemsToCart('A', 5); data.AddItemsToCart('B', 5); data.AddItemsToCart('C', 1); decimal result = data.CalculateCheckOutPrice(); Assert.Equal(370, result); }
public ActionResult Exam(StudentExamViewModel examViewModel) { var quizes = InMemoryData.GetQuizData(); var quiz = quizes.FirstOrDefault(q => q.Id == examViewModel.QuizId); if (quiz != null) { var examResult = GetExamResult(examViewModel.StudentName, quiz, examViewModel); return(View("ExamResult", examResult)); } return(View("ExamResult", new ExamResult(examViewModel.StudentName, examViewModel.QuizText, 100, 0))); }
static void Main(string[] args) { // Unity IoC container to resolve dependency injection var container = new UnityContainer(); container.RegisterType <IFileGenerator, CSVFileGenerator>(); container.RegisterType <ICustomConfiguration, CustomConfiguration>(); container.RegisterType <ITreeBuildService, TreeBuildService>(); InMemoryData datatree = container.Resolve <InMemoryData>(); datatree.GenerateFile(); }
public ActionResult Exam(UserSelection userSelection) { var quizData = InMemoryData.GetQuizData(); var quiz = quizData.FirstOrDefault(q => q.Id == userSelection.QuizId); if (quiz != null) { var examVm = BuildExamVm(userSelection.StudentName, quiz); return(View(examVm)); } return(View(new StudentExamViewModel())); }
public async Task ドキュメント更新のイベントが登録される() { var document1 = DocumentUtils.Create("path1/subpath1/content1.txt", "Hello, World"); var ev1 = document1.DomainEvents.First(); await sut.Handle(new DomainEventNotification <DocumentCreatedEvent>(ev1 as DocumentCreatedEvent)); document1.ClearDomainEvents(); document1.Update("application/json", InMemoryData.Create("storagekey2", Encoding.UTF8.GetBytes("Hello, New World"))); var ev2 = document1.DomainEvents.First(); await sut.Handle(new DomainEventNotification <DocumentUpdatedEvent>(ev2 as DocumentUpdatedEvent)); Assert.AreEqual(1, await ctx.DocumentHistories.Where(f => f.Path == "path1/subpath1/content1.txt" && f.Discriminator == DocumentHistoryDiscriminator.DocumentCreated).CountAsync()); Assert.AreEqual(1, await ctx.DocumentHistories.Where(f => f.Path == "path1/subpath1/content1.txt" && f.Discriminator == DocumentHistoryDiscriminator.DocumentUpdated).CountAsync()); }
//コンストラクタ public BookController(BookContext context) { _context = context; if (_context.Books.Count() == 0) { //インメモリDB用初期データ投入 var imd = new InMemoryData(_context); imd.CategoryDataInsert(); imd.StatusDataInsert(); imd.AuthorDataInsert(); imd.BookDataInsert(); } }
public void linq_example() { var data = new InMemoryData().BuildData(); var activeUsers = (from user in data.Users where user.AccountStatus == AccountStatus.Active select user).ToList(); var flattened = (from user in data.Users from subscription in user.Subscriptions select new { subscription, user } ).ToList(); }
public async Task ファイルが更新された場合正しく更新されること() { var document1 = DocumentUtils.Create("path1/subpath1/content1.txt", "path1/subpath1/content1.txt"); var ev1 = document1.DomainEvents.First(); await sut.Handle(new DomainEventNotification <DocumentCreatedEvent>(ev1 as DocumentCreatedEvent)); var bytes2 = Encoding.UTF8.GetBytes("path1/subpath1/content1.txt updated"); document1.ClearDomainEvents(); document1.Update("application/json", InMemoryData.Create("storagekey2", bytes2)); var ev2 = document1.DomainEvents.First(); await sut.Handle(new DomainEventNotification <DocumentUpdatedEvent>(ev2 as DocumentUpdatedEvent)); Assert.AreEqual("application/json", (await ctx.Blobs.FirstAsync(f => f.Path == "path1/subpath1/content1.txt")).ContentType); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //Adding some test data at start up. using (var serviceScope = app.ApplicationServices.CreateScope()) { var context = serviceScope.ServiceProvider.GetService <ApiContext>(); InMemoryData.Add(context); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
protected override void AddSafe <T>(T item) { InMemoryData.Add(item as DynamicRelation); }
protected override IEnumerable <T> AsEnumerableSafe <T>() { //return a cloned list because the types can be changed. //this is not safe enough but at least something. definitely a TODO return(InMemoryData.Cast <T>().Where(relation => CanUse(relation))); }
public GetCheeses(InMemoryData inMemoryData) { _inMemoryData = inMemoryData; }
public DeletePerson(InMemoryData inMemoryData) { _inMemoryData = inMemoryData; }
public GetPeople(InMemoryData inMemoryData) { _inMemoryData = inMemoryData; }