public async Task AddBlog_Return_Ok_With_Added_Blog()
        {
            // Arrange
            HttpResponseMessage expectedRespone = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
            RubiconContext      db   = _server.Services.GetService(typeof(RubiconContext)) as RubiconContext;
            Tag            tag       = db.Tags.Take(1).First();
            DataGeneration generator = new DataGeneration();


            AddBlogModel addBlogModel = new AddBlogModel()
            {
                Body        = "ttttt",
                Description = "tttt",
                TagList     = new List <string>(),
                Title       = generator.GenerateStringRandomLenght(10, 30)
            };

            addBlogModel.TagList.Add(tag.Name);

            var Client  = new RestClient("http://localhost:57595/");
            var Request = new RestRequest("api/Posts").AddJsonBody(addBlogModel);


            //Act
            var response = await Client.ExecutePostAsync(Request);

            BlogModel blogsModel = new JsonDeserializer().Deserialize <BlogModel>(response);


            //Arrange
            Assert.Equal(expectedRespone.StatusCode, response.StatusCode);
            Assert.True(blogsModel != null);
        }
        public async Task UpdateBlog_Return_Ok_Return_UpdatedBlog()
        {
            // Arrange
            HttpResponseMessage expectedRespone = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
            RubiconContext      db = _server.Services.GetService(typeof(RubiconContext)) as RubiconContext;
            Blog           blog    = db.Blogs.Take(1).First();//get a random blog that is allready taken
            DataGeneration data    = new DataGeneration();

            UpdateBlogModel addBlogModel = new UpdateBlogModel()
            {
                Slug        = blog.Slug,
                Body        = data.GenerateStringRandomLenght(10, 30),
                Description = data.GenerateStringRandomLenght(10, 30),
                Title       = data.GenerateStringRandomLenght(10, 30)
            };

            var Client  = new RestClient("http://localhost:57595/");
            var Request = new RestRequest("api/Posts", Method.PUT).AddJsonBody(addBlogModel);

            //Act
            var response = await Client.ExecuteAsync(Request);

            BlogModel blogModel = new JsonDeserializer().Deserialize <BlogModel>(response);


            //Arrange
            Assert.Equal(expectedRespone.StatusCode, response.StatusCode);
            Assert.True(blogModel != null);
        }
        private async void AlgorithmPanel_Paint(object sender, PaintEventArgs e)
        {
            Graphics graphics = algorithmPanel.CreateGraphics();

            int maxWidth  = algorithmPanel.Width / elementCount; //Width of each
            int maxHeight = algorithmPanel.Height;               //Max Height of the panel

            elements = DataGeneration.GetData(maxHeight, elementCount, setModifier);

            for (int i = 0; i < elementCount; i++)
            {
                graphics.FillRectangle(new SolidBrush(Color.Black), i * maxWidth, maxHeight - elements[i], maxWidth, elements[i]);
            }

            algorithm.maxWidth     = maxWidth;
            algorithm.maxHeight    = maxHeight;
            algorithm.graphics     = graphics;
            algorithm.elementCount = elements.Length;

            Thread.Sleep(500);

            await Task.Run(() => BeginSorting(graphics, maxWidth, maxHeight, elements));

            SortComplete = true;
            algorithm.ShowCompletedDisplay(elements);
        }
Example #4
0
            public InsertStatementGenerator(Mapper mapper, int count, string tag)
            {
                _mapper           = mapper;
                _tableMapping     = _mapper._tableMappings[typeof(T)];
                _insertStatements = new GeneratorInsertAction(_tableMapping.Table)
                {
                    Tag    = tag,
                    Schema = mapper.Schema
                };

                if (_tableMapping.DatabaseGenerated)
                {
                    var primaryKeyColumn = _tableMapping.Table
                                           .Constraints
                                           .OfType <PrimaryKeyConstraint>()
                                           .Single()
                                           .SingleAffectedColumn;

                    int startValue = _tableMapping.PrimaryKeySequence.StartWith ?? 0;
                    _primaryKeyGenerator = DataGeneration.Count(startValue);
                    _tableMapping.PrimaryKeySequence.StartWith = startValue + count;
                    _insertStatements.Generators.Add(primaryKeyColumn, _primaryKeyGenerator);
                }

                _insertStatements.Generate(count);
            }
Example #5
0
        public MainWindow()
        {
            DataGeneration datagen = new DataGeneration();

            shoplogic.ParseData(datagen.GiveData());
            InitializeComponent();
            updateLists();
        }
Example #6
0
        public void ExtractClaimsBytes_Returns_Right_Amount_Of_Guids(int numclaims)
        {
            var guids = DataGeneration.GenerateByteArrayClaims(numclaims);

            var expected = numclaims;
            var actual   = ClaimParsing.ExtractClaims(guids).Count();

            Assert.Equal(expected, actual);
        }
        public async Task GetAll_RetrievesSuccessfully()
        {
            _launchpadRepository.Setup(mock => mock.GetAllAsync()).ReturnsAsync(DataGeneration.GenerateLaunchpadCollection(3));

            var svcResult = await GetService().GetAllAsync();

            svcResult.Count().Should().Be(3);

            VerifyAll();
        }
Example #8
0
        public void GenerateStringClaims_Generates_Right_Amount_Of_Guids(int numclaims)
        {
            var guids = DataGeneration.GenerateStringClaims(numclaims);

            // With hypens one guid should be 36 chars
            var expected = numclaims * 36;
            var actual   = guids.Length;

            Assert.NotNull(guids);
            Assert.Equal(expected, actual);
        }
Example #9
0
        private void New(NewMessage msg)
        {
            HexMapCreationInputDialog dialog = new HexMapCreationInputDialog(
                "Title", "Label", 10, 5);

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ApplicationModel.GameModel.ImportData(DataGeneration.GenerateGameData(dialog.Result.Item1, dialog.Result.Item2));
                ApplicationViewModel.GameViewModel.ApplyModel(ApplicationModel.GameModel);
            }
        }
Example #10
0
        public void GenerateByteArrayClaims_Generates_Right_Amount_Of_Guids(int numclaims)
        {
            var guids = DataGeneration.GenerateByteArrayClaims(numclaims);

            // lets just do it he microsoft way
            // https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/Guid.cs#L50
            var actual   = guids.Length;
            var expected = numclaims * 16;

            Assert.NotNull(guids);
            Assert.Equal(expected, actual);
        }
        public async Task GetById_RetrievesSuccessfully()
        {
            const string id = "12345";

            _launchpadRepository.Setup(mock => mock.GetByIdAsync(id)).ReturnsAsync(DataGeneration.GenerateLaunchpad());

            var svcResult = await GetService().GetByIdAsync(id);

            svcResult.Should().NotBeNull();

            VerifyAll();
        }
Example #12
0
        public void Ascending(DataSource source, DataFilter filter)
        {
            var input = new MappedInterval <Crate> [10];

            DataGeneration.LikeReal(source, filter, MakeCrate, input);

            var whole = new Tuple <int, int> [1];

            whole[0] = Tuple.Create(0, input.Length);
            AddSeries(input, whole);

            CollectionAssert.AreEqual(_sut, input);
        }
Example #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, PropertyContext propertyContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            AutoMapper.Mapper.Initialize(config =>
            {
                config.CreateMap <Tenant, TenantDto>()
                .ForMember(dest => dest.Name, opt => opt
                           .MapFrom(src => $"{src.FirstName} {src.LastName}"));

                config.CreateMap <Property, PropertyDto>();
                config.CreateMap <PropertyForCreationDto, Property>();
                config.CreateMap <TenantForCreationDto, Tenant>();
            });

            DataGeneration.SeedDataForDevelopment(propertyContext);

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    "default",
                    "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                // To learn more about options for serving an Angular SPA from ASP.NET Core,
                // see https://go.microsoft.com/fwlink/?linkid=864501

                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer("start");
                }
            });
        }
Example #14
0
        public SystemWideLogEntry(DateTime date, FileAccessStatus status)
        {
            DateTimeOfAccess = date.Date.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture);
            Region           = DataGeneration.GetRandomRegion();
            TenantName       = faker.Person.FirstName;
            UserName         = faker.Person.UserName;
            FileName         = faker.System.FileName("tsv");
            Status           = status;

            if (status == FileAccessStatus.Error)
            {
                Exception = faker.System.Exception().GetType().ToString();
            }
        }
Example #15
0
        public void RandomAscendingSeries(DataSource source, DataFilter filter)
        {
            var input = new MappedInterval <Crate> [10];

            DataGeneration.LikeReal(source, filter, MakeCrate, input);

            var preRanges = GeneratePartitions(input.Length).ToArray();
            var ranges    = new Tuple <int, int> [preRanges.Length];

            Shuffle(preRanges, ranges);

            AddSeries(input, ranges);

            CollectionAssert.AreEqual(_sut, input);
        }
Example #16
0
        public PerFileLogEntry(DateTime date)
        {
            var random = new Random();

            Date           = date.Date;
            Region         = DataGeneration.GetRandomRegion();
            TenantName     = FakeCompanies.CompanyName();
            FileName       = FakeSystem.FileName();
            ModifyingUsers = GenerateUsersString();
            FirstAccess    = Date.AddHours(random.Next(0, 6))
                             .AddMinutes(random.Next(0, 59))
                             .AddSeconds(random.Next(0, 59));
            LastAccess = Date.AddHours(random.Next(11, 23))
                         .AddMinutes(random.Next(0, 59))
                         .AddSeconds(random.Next(0, 59));
        }
Example #17
0
        /// <summary>
        /// Creates a per-file log entry for the given date.
        /// </summary>
        /// <param name="date">The date for which the log entry should be created.</param>
        public PerFileLogEntry(DateTime date)
        {
            var random = new Random();

            this.Date           = date.Date;
            this.Region         = DataGeneration.GetRegion();
            this.TenantName     = new Bogus.DataSets.Company().CompanyName();
            this.FileName       = new Bogus.DataSets.System().FileName();
            this.ModifyingUsers = GenerateUsersString();
            this.FirstAccess    = this.Date.AddHours(random.Next(0, 6))
                                  .AddMinutes(random.Next(0, 59))
                                  .AddSeconds(random.Next(0, 59));
            this.LastAccess = this.Date.AddHours(random.Next(18, 23))
                              .AddMinutes(random.Next(0, 59))
                              .AddSeconds(random.Next(0, 59));
        }
        public async Task GetAll_WithMultipleKeywordFilterMatch_Success()
        {
            var launchpads = new List <LaunchpadViewModel>()
            {
                DataGeneration.GenerateLaunchpad(name: "Common Name"),
                DataGeneration.GenerateLaunchpad(name: "This is in Common"),
                DataGeneration.GenerateLaunchpad(name: "Maybe this one should return"),
            };

            _launchpadRepository.Setup(mock => mock.GetAllAsync()).ReturnsAsync(launchpads);

            var svcResult = await GetService().GetAllAsync(new string[] { "common", "should" });

            svcResult.Count().Should().Be(3);

            VerifyAll();
        }
        public async Task GetAll_WithKeywordFilterNoMatch_ReturnsEmpty()
        {
            var launchpads = new List <LaunchpadViewModel>()
            {
                DataGeneration.GenerateLaunchpad(name: "Common Name"),
                DataGeneration.GenerateLaunchpad(name: "This is in Common"),
                DataGeneration.GenerateLaunchpad(name: "Nope, don't return this"),
            };

            _launchpadRepository.Setup(mock => mock.GetAllAsync()).ReturnsAsync(launchpads);

            var svcResult = await GetService().GetAllAsync(new string[] { "tacos" });

            svcResult.Count().Should().Be(0);

            VerifyAll();
        }
        public async Task GetAll_WithStatusFilterNoMatch_ReturnsEmpty()
        {
            var launchpads = new List <LaunchpadViewModel>()
            {
                DataGeneration.GenerateLaunchpad(status: "active"),
                DataGeneration.GenerateLaunchpad(status: "active"),
                DataGeneration.GenerateLaunchpad(status: "under construction"),
            };

            _launchpadRepository.Setup(mock => mock.GetAllAsync()).ReturnsAsync(launchpads);

            var svcResult = await GetService().GetAllAsync(new string[] { "retired" });

            svcResult.Count().Should().Be(0);

            VerifyAll();
        }
        public async Task GetAll_WithStatusAndNameFilterMatch_Success()
        {
            var launchpads = new List <LaunchpadViewModel>()
            {
                DataGeneration.GenerateLaunchpad(status: "active"),
                DataGeneration.GenerateLaunchpad(status: "active"),
                DataGeneration.GenerateLaunchpad(status: "under construction", name: "Taco and Burrito Launchpad"),
                DataGeneration.GenerateLaunchpad(status: "under construction"),
            };

            _launchpadRepository.Setup(mock => mock.GetAllAsync()).ReturnsAsync(launchpads);

            var svcResult = await GetService().GetAllAsync(new string[] { "active", "taco" });

            svcResult.Count().Should().Be(3);

            VerifyAll();
        }
Example #22
0
        public void RandomSeriesBatched(DataSource source, DataFilter filter)
        {
            var input = new MappedInterval <Crate> [10];

            DataGeneration.LikeReal(source, filter, MakeCrate, input);

            var preRanges = GeneratePartitions(input.Length).ToArray();
            var ranges    = new Tuple <int, int> [preRanges.Length];

            Shuffle(preRanges, ranges);

            foreach (var range in ranges)
            {
                _sut.Put(new ArraySegment <MappedInterval <Crate> >(input, range.Item1, range.Item2 - range.Item1));
            }

            CollectionAssert.AreEqual(_sut, input);
        }
Example #23
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ApplicationData applicationData = new ApplicationData();

            applicationData.UIData = DataGeneration.GenerateUIData();

            ApplicationModel = new ApplicationModel();
            ApplicationModel.ImportData(applicationData);

            ApplicationViewModel = new ApplicationViewModel();
            ApplicationViewModel.ApplyModel(ApplicationModel);
            ApplicationViewControl.DataContext = ApplicationViewModel;

            BaseLogic = new GameLogic();
            Messenger.Default.Register <NewMessage>(this, New);
            Messenger.Default.Register <LoadMessage>(this, Load);
            Messenger.Default.Register <SaveMessage>(this, Save);
            Messenger.Default.Register <QuitMessage>(this, Quit);
        }
        public async void GetAllById_ReturnsSingleLaunchpad()
        {
            var id = "abc_342";
            LaunchpadViewModel lp = DataGeneration.GenerateLaunchpad();

            lp.Id = id;
            _launchpadRetrievalServices.Setup(mock => mock.GetByIdAsync(id)).ReturnsAsync(lp);

            var response = await GetController().GetById(id);

            response.Result.Should().BeOfType <OkObjectResult>();
            var result = (OkObjectResult)response.Result;

            result.Value.Should().NotBeNull();
            result.Value.Should().BeOfType <LaunchpadViewModel>();
            var launchpad = (LaunchpadViewModel)result.Value;

            launchpad.Id.Should().Be(id);

            VerifyAll();
        }
Example #25
0
        static void Main()
        {
            Console.WriteLine("Starting");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form1 base_form = new Form1();

            // Start of the fun stuff
            DataGeneration data_gen = new DataGeneration();
            Schedule       schedule = data_gen.GenerateDataset();

            // Get ready to sort!
            schedule.CreateSortingMatrix();
            Sorter schedule_sorter = new Sorter(ref schedule);

            // Add students to requested classes
            schedule_sorter.AddStudents();

            // Print some things
            Console.WriteLine("Writing to the grid now");
            //base_form.textBoxSchedule.AppendText("Unsorted classes\n");
            //print_courses(ref base_form, ref schedule);

            // Order courses
            schedule_sorter.OrderCoursesBySize();
            base_form.textBoxSchedule.AppendText("Sorted classes\n");
            print_courses(ref base_form, ref schedule);

            // Print out student info for now
            print_student_info(ref base_form, ref schedule);

            // Create sorting matrix
            schedule_sorter.FindConflicts();

            // Print sorting matrix
            print_sorting_matrix(ref base_form, ref schedule);

            // Show the form, blocks
            Application.Run(base_form);
        }
Example #26
0
 public void Setup()
 {
     Data     = DataGeneration.GenerateStringClaims(NumClaims);
     byteData = DataGeneration.GenerateByteArrayClaims(NumClaims);
 }
        public async void GetAll_ReturnsLaunchpadsResult()
        {
            _launchpadRetrievalServices.Setup(mock => mock.GetAllAsync(null)).ReturnsAsync(DataGeneration.GenerateLaunchpadCollection(5));

            var response = await GetController().GetAll();

            response.Result.Should().BeOfType <OkObjectResult>();
            var result = (OkObjectResult)response.Result;

            result.Value.Should().NotBeNull();
            var launchpads = (IEnumerable <LaunchpadViewModel>)result.Value;

            launchpads.Count().Should().Be(5);

            VerifyAll();
        }
        public async void GetAll_WithMultipleKeywords_ReturnsLaunchpadsResult()
        {
            _launchpadRetrievalServices.Setup(mock => mock.GetAllAsync(new string[] { "active", "air force" })).ReturnsAsync(DataGeneration.GenerateLaunchpadCollection(2));

            var response = await GetController().GetAll("active,air force");

            response.Result.Should().BeOfType <OkObjectResult>();
            var result = (OkObjectResult)response.Result;

            result.Value.Should().NotBeNull();
            var launchpads = (IEnumerable <LaunchpadViewModel>)result.Value;

            launchpads.Count().Should().Be(2);

            VerifyAll();
        }
 public ApplicationData(int colCount, int rowCount)
 {
     UIData   = DataGeneration.GenerateUIData();
     GameData = DataGeneration.GenerateGameData(colCount, rowCount);
 }
Example #30
0
 public void GenerateByteArrayClaims_Generates_Throws_Right_Exception()
 {
     Assert.Throws <ArgumentNullException>(()
                                           => DataGeneration.GenerateByteArrayClaims(0));
 }