예제 #1
0
 public void InitializeTest( )
 {
     personGenerator = DataGenerator <Person> .Create(null)
                       .RuleFor(o => o.Id, f => personId++)
                       .RuleFor(o => o.Birthdate, f => DataTests.GetBirthdate(f))
                       .RuleFor(o => o.Gender, f => DataTests.GetGender(f.Random.Int(1, 3)))
                       .RuleFor(o => o.Forename, (f, o) => DataTests.GetForename(f, o))
                       .RuleFor(o => o.Segname, (f, o) => DataTests.GetSegname(f, o))
                       .RuleFor(o => o.Surname, f => f.Name.LastName());
 }
예제 #2
0
        private void startDataGeneration()
        {
            var generator = DataGenerator.Create(Common.WorkingDefinition);

            generator.ProgressChanged += Generator_ProgressChanged;
            this.Cursor    = Cursors.WaitCursor;
            _isRunning     = true;
            _timer.Enabled = true;
            _bgWorker      = new BackgroundWorker();
            _bgWorker.WorkerReportsProgress = true;
            _bgWorker.RunWorkerCompleted   += bgWorker_RunWorkerCompleted;
            _bgWorker.DoWork += bgWorker_DoWork;
            _bgWorker.RunWorkerAsync(generator);
        }
예제 #3
0
        public void GetItemsAsync_UserFound_ShouldReturnAllItemsByUsername()
        {
            var fakeUsername = DataGenerator.Create <string>();
            var fakeUser     = new User {
                UserName = fakeUsername
            };
            var fakeItems = DataGenerator.CreateMany <Item>(3).ToList();

            fakeItems.ForEach(x => x.User = fakeUser);

            this._onebrbContext.Setup(x => x.GetItemsAsync(fakeUsername))
            .ReturnsAsync(fakeItems);

            Assert.True(fakeItems.TrueForAll(x => x.User == fakeUser));
        }
예제 #4
0
        public async void GetItemAsync_ItemFound_ShouldReturnItem()
        {
            int itemId = DataGenerator.Create <int>();

            var fakeItem = new Item {
                Id = itemId
            };

            var fakeItemServiceModel = new ItemServiceModel
            {
                Id = itemId,
            };

            _onebrbContext.Setup(x => x.GetItemAsync(itemId))
            .ReturnsAsync(fakeItem);

            ItemServiceModel result = await _itemService.GetItemAsync(itemId);

            Assert.NotNull(result);
            Assert.Equal(result.Id, fakeItem.Id);
        }