コード例 #1
0
        public DataPersistenceTests(DataContext dataContext, IConfiguration configuration)
        {
            _configuration = configuration;
            _dataContext   = dataContext;

            RepresentativeDataController = new RepresentativeDataController(_dataContext, _configuration);
            PortsOfEntryController       = new PortsOfEntryController(_dataContext, _configuration);
            ScreeningDataTableController = new ScreeningDataTableController(_dataContext, _configuration);
        }
コード例 #2
0
        public void CanGenerateSampleData()
        {
            // create some ports of entry
            for (int i = 0; i < 10; i++)
            {
                var portOfEntry = CreateRandomPortOfEntry();
                portOfEntry.Should().NotBeNull();
                var postResult   = PortsOfEntryController.Post(portOfEntry);
                var createdReult = postResult.Result as CreatedResult;
                (createdReult.Value as PortsOfEntry).Should().NotBeNull();
                (createdReult.Value as PortsOfEntry).Id.Should().NotBe(Guid.Empty);
            }

            // create some reps
            for (int i = 0; i < 10; i++)
            {
                var rep          = CreateRandomRepresentative();
                var postResult   = RepresentativeDataController.Post(rep);
                var createdReult = postResult.Result as CreatedResult;
                (createdReult.Value as RepresentativeData).Should().NotBeNull();
                (createdReult.Value as RepresentativeData).Id.Should().NotBe(Guid.Empty);
            }

            // get back the reps
            var reps = RepresentativeDataController.Get();

            // create some screenings
            for (int i = 0; i < 10; i++)
            {
                var rep = GetRandomRepresentative(reps);
                rep.Should().NotBeNull();
                var screen       = CreateRandomScreeningData(rep.RepName);
                var postResult   = ScreeningDataTableController.Post(screen);
                var createdReult = postResult.Result as CreatedResult;
                (createdReult.Value as ScreeningDataTable).Should().NotBeNull();
                (createdReult.Value as ScreeningDataTable).Id.Should().NotBe(Guid.Empty);
            }
        }
コード例 #3
0
        RepresentativeData GetRandomRepresentative()
        {
            var reps = RepresentativeDataController.Get();

            return(GetRandomRepresentative(reps));
        }
コード例 #4
0
        RepresentativeData GetRandomRepresentative()
        {
            var reps = RepresentativeDataController.Get();

            return(reps.ElementAt(new Random().Next(0, (reps.Count() - 1))));
        }