public void AutoFillList_FillWith3Elements() { var element = AutoFill <TestList> .One(); Assert.That(element.IntValues, Is.EquivalentTo(new[] { 1, 2, 3 })); Assert.That(element.StringValues, Is.EquivalentTo(new[] { "some-string-values0", "some-string-values1", "some-string-values2" })); }
public void AutoFillStringValue_WithRandomFlag_SuffixRandomValue() { var element = AutoFill <TestStringClass> .One(AutoFillFlags.RandomizeString); Assert.That(element.Name, Does.Match("^some-name-([a-f0-9]{16})$")); Assert.That(element.Description, Does.Match("^some-description-([a-f0-9]{16})$")); Assert.That(element.MultipleWordProperty, Does.Match("^some-multiple-word-property-([a-f0-9]{16})$")); }
public void AutoFillStringValue_PrefixVariableNameWithSome() { var element = AutoFill <TestStringClass> .One(); Assert.That(element.Name, Does.Match("^some-name$")); Assert.That(element.Description, Does.Match("^some-description$")); Assert.That(element.MultipleWordProperty, Does.Match("^some-multiple-word-property$")); }
public void AutoFill_DoNotFilIgnoredFields() { var element = AutoFill <TestIgnoring> .One(ignoring : (i) => new { i.Ignored, i.Child.SubIgnored }); Assert.That(element.Value, Is.EqualTo(1)); Assert.That(element.Ignored, Is.Null); Assert.That(element.Child.SubIgnored, Is.Null); }
public void AutoFillRecursiveObject_StopWhenMaxDepthIsReached() { var element = AutoFill <TestRecursive> .One(settings : new AutoFillSettings { MaxDepth = 1 }); Assert.That(element.Recursive.Recursive, Is.Null); }
public void AutoFillObject_ContinueIncrementing() { var element = AutoFill <TestObjectType> .One(); Assert.That(element.IntValue, Is.EqualTo(1)); Assert.That(element.SubObject, Is.Not.Null); Assert.That(element.SubObject.SubIntValue, Is.EqualTo(2)); }
public void EditEffect_WhenEffectDoesNotExists_Throw() { var executionContext = new NaheulbookExecutionContext(); var editEffectRequest = AutoFill <EditEffectRequest> .One(); _effectRepository.GetWithModifiersAsync(Arg.Any <int>()) .Returns((Effect)null); Func <Task> act = () => _effectService.EditEffectAsync(executionContext, 42, editEffectRequest); act.Should().Throw <EffectNotFoundException>(); }
public async Task CreateEffectType_AddANewEffectTypeInDatabase() { var createEffectTypeRequest = AutoFill <CreateEffectTypeRequest> .One(); var effectType = await _effectService.CreateEffectTypeAsync(new NaheulbookExecutionContext(), createEffectTypeRequest); Received.InOrder(() => { _effectTypeRepository.Add(effectType); _unitOfWork.SaveChangesAsync(); }); effectType.Name.Should().Be("some-name"); }
public async Task CreateEffect_EnsureThatUserIsAnAdmin_BeforeAddingInDatabase() { var executionContext = new NaheulbookExecutionContext(); var createEffectRequest = AutoFill <CreateEffectRequest> .One(); await _effectService.CreateEffectAsync(executionContext, 2, createEffectRequest); Received.InOrder(() => { _authorizationUtil.EnsureAdminAccessAsync(executionContext); _unitOfWork.SaveChangesAsync(); }); }
public void AutoFillIntegerValues_IncrementByOne() { var element = AutoFill <TestIntClass> .One(); Assert.That(element.IntValue, Is.EqualTo(1)); Assert.That(element.ShortValue, Is.EqualTo(2)); Assert.That(element.CharValue, Is.EqualTo(3)); Assert.That(element.LongValue, Is.EqualTo(4)); Assert.That(element.ByteValue, Is.EqualTo(5)); Assert.That(element.FloatValue, Is.EqualTo(6)); Assert.That(element.DoubleValue, Is.EqualTo(7)); Assert.That(element.DecimalValue, Is.EqualTo(8)); Assert.That(element.BoolValue, Is.EqualTo(true)); }
public async Task CreateEffect_AddANewEffectInDatabase() { var expectedEffect = CreateEffect(subCategoryId: 2); var createEffectRequest = AutoFill <CreateEffectRequest> .One(); var executionContext = new NaheulbookExecutionContext(); var effect = await _effectService.CreateEffectAsync(executionContext, 2, createEffectRequest); Received.InOrder(() => { _effectRepository.Add(effect); _unitOfWork.SaveChangesAsync(); }); effect.Should().BeEquivalentTo(expectedEffect); }
public async Task CreateEffectSubCategory_AddANewEffectSubCategoryInDatabase() { var expectedEffectSubCategory = CreateEffectSubCategory(); expectedEffectSubCategory.Effects = new List <Effect>(); var createEffectSubCategoryRequest = AutoFill <CreateEffectSubCategoryRequest> .One(); var effectSubCategory = await _effectService.CreateEffectSubCategoryAsync(new NaheulbookExecutionContext(), createEffectSubCategoryRequest); Received.InOrder(() => { _effectSubCategoryRepository.Add(effectSubCategory); _unitOfWork.SaveChangesAsync(); }); effectSubCategory.Should().BeEquivalentTo(expectedEffectSubCategory); }
public async Task CreateItemTemplateSubCategory_AddANewItemTemplateSubCategoryInDatabase() { var expectedItemTemplateSubCategory = CreateItemTemplateSubCategoryAsync(); var createItemTemplateSubCategoryRequest = AutoFill <CreateItemTemplateSubCategoryRequest> .One(settings : new AutoFillSettings { MaxDepth = 0 }); var itemTemplateSubCategory = await _itemTemplateSubCategoryService.CreateItemTemplateSubCategoryAsync(new NaheulbookExecutionContext(), createItemTemplateSubCategoryRequest); Received.InOrder(() => { _itemTemplateSubCategoryRepository.Add(itemTemplateSubCategory); _unitOfWork.SaveChangesAsync(); }); itemTemplateSubCategory.Should().BeEquivalentTo(expectedItemTemplateSubCategory); }
public async Task CreateItemTemplateSection_AddANewItemTemplateSectionInDatabase() { var expectedItemTemplateSection = CreateItemTemplateSection(); var createItemTemplateSectionRequest = AutoFill <CreateItemTemplateSectionRequest> .One(settings : new AutoFillSettings { MaxDepth = 0 }); var itemTemplateSection = await _service.CreateItemTemplateSectionAsync(new NaheulbookExecutionContext(), createItemTemplateSectionRequest); var itemTemplateSectionRepository = _unitOfWorkFactory.GetUnitOfWork().ItemTemplateSections; Received.InOrder(() => { itemTemplateSectionRepository.Add(itemTemplateSection); _unitOfWorkFactory.GetUnitOfWork().SaveChangesAsync(); }); itemTemplateSection.Should().BeEquivalentTo(expectedItemTemplateSection); }
public async Task EditEffect_EnsureThatUserIsAnAdmin_BeforeAddingInDatabase() { var executionContext = new NaheulbookExecutionContext(); var previousEffect = AutoFill <Effect> .One(AutoFillFlags.RandomizeString | AutoFillFlags.RandomInt); var editEffectRequest = AutoFill <EditEffectRequest> .One(); previousEffect.Id = 42; _effectRepository.GetWithModifiersAsync(42) .Returns(previousEffect); await _effectService.EditEffectAsync(executionContext, 42, editEffectRequest); Received.InOrder(() => { _authorizationUtil.EnsureAdminAccessAsync(executionContext); _unitOfWork.SaveChangesAsync(); }); }
public async Task EditEffect_UpdateEffectInDatabase() { var expectedEffect = CreateEffect(42, subCategoryId: 1, offset: 1); var executionContext = new NaheulbookExecutionContext(); var previousEffect = AutoFill <Effect> .One(AutoFillFlags.RandomizeString | AutoFillFlags.RandomInt, new AutoFillSettings { MaxDepth = 1 }, (i) => new { Category = i.SubCategory }); var editEffectRequest = AutoFill <EditEffectRequest> .One(); previousEffect.Id = 42; _effectRepository.GetWithModifiersAsync(42) .Returns(previousEffect); await _effectService.EditEffectAsync(executionContext, 42, editEffectRequest); await _unitOfWork.Received(1) .SaveChangesAsync(); previousEffect.Should().BeEquivalentTo(expectedEffect); }