Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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");
        }
Esempio n. 3
0
        public void Should_Not_Find_Vehicle()
        {
            var inMemoryRepository = new InMemoryData <Vehicle>(_logger.Object);
            var result             = inMemoryRepository.Find(new Guid());

            Assert.Equal(null, result);
        }
Esempio n. 4
0
        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());
            }
        }
Esempio n. 5
0
        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");
        }
Esempio n. 6
0
        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");
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        public ActionResult Index()
        {
            var loginVm = new LoginVm();

            loginVm.StudentName = "*****@*****.**";
            //This could be read form database
            loginVm.Quizzes.AddRange(BuildQuizVm(InMemoryData.GetQuizData()));
            return(View(loginVm));
        }
Esempio n. 9
0
        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");
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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");
        }
Esempio n. 12
0
        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");
        }
Esempio n. 13
0
 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));
 }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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));
        }
Esempio n. 16
0
        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");
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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)));
        }
Esempio n. 19
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();
        }
Esempio n. 20
0
        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());
        }
Esempio n. 22
0
        //コンストラクタ
        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();
            }
        }
Esempio n. 23
0
        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)));
 }
Esempio n. 28
0
 public GetCheeses(InMemoryData inMemoryData)
 {
     _inMemoryData = inMemoryData;
 }
Esempio n. 29
0
 public DeletePerson(InMemoryData inMemoryData)
 {
     _inMemoryData = inMemoryData;
 }
Esempio n. 30
0
 public GetPeople(InMemoryData inMemoryData)
 {
     _inMemoryData = inMemoryData;
 }