public void TypeDefinitionDataNameTest() { var t = typeof(TestClassDefinition); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); AssertX.Equal(t.Name, typeData.Name, "The Name is not assigned correctly."); }
public void EnumerableSelectReturnsIEnumerable() { var array = Creator.New(() => new BasicTypes()).Array(); var result = array.SelectNew <BasicTypes>(); AssertX.AssignableFrom(result, typeof(IEnumerable <BasicTypes>)); }
public void MultiplePiecesOfMetadataAreCombinedIntoAnArray() { var cc = CreateContainer(typeof(MultipleNames)); var withNames = cc.GetExport <Lazy <MultipleNames, MultiValuedName> >(); AssertX.Equivalent(new[] { "A", "B", "B" }, withNames.Metadata.Name); }
public void QueryableSelectReturnsIQueryable() { var query = Creator.New(() => new BasicTypes()).Queryable(); var result = query.SelectNew <BasicTypes>(); AssertX.AssignableFrom(result, typeof(IQueryable <BasicTypes>)); }
public void QueryableSelectReturnsIQueryable() { var query = Creator.New(() => new ObjectType()).Queryable(); var result = query.SelectFields("Id"); AssertX.AssignableFrom(result, typeof(IQueryable <object>)); }
public void Add_ReturnsViewResult() { var subject = _fixture.Create <CanonicalSkillController>(); var actionResult = subject.Add(); AssertX.IsViewResult(actionResult); }
public void EnumerableSelectReturnsIEnumerable() { var array = Creator.New(() => new ObjectType()).Array(); var result = array.SelectFields("Id"); AssertX.AssignableFrom(result, typeof(IEnumerable <object>)); }
public void Register_ReturnsAViewResult() { AccountController subject = _fixture.Create <AccountController>(); ActionResult actionResult = subject.Register(); AssertX.IsViewResultWithModelOfType <RegisterViewModel>(actionResult); }
public void FieldDataNameTest() { var t = typeof(TestClassDefinition); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); var field = typeData.GetMember("FieldInstance"); AssertX.Equal("FieldInstance", field.Name, "The Name of the member is incorrect."); }
public void FieldDataDeclaringTypeTest() { var t = typeof(TestClassDefinition); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); var field = typeData.GetMember("FieldInstance"); AssertX.Equal(typeData, field.ContainingType, "The DeclaringType of a member should be the type in which it is defined."); }
public void OperatorDataNameTest() { var t = typeof(VariousMemberFeatures); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); var method = typeData.GetMember("op_Addition"); AssertX.Equal("op_Addition", method.Name, "The Name of the member is incorrect."); }
public void OperatorDataDeclaringTypeTest() { var t = typeof(VariousMemberFeatures); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); var method = typeData.GetMember("op_Addition"); AssertX.Equal(typeData, method.ContainingType, "The DeclaringType of a member should be the type in which it is defined."); }
public async Task EditContactInfo_GivenIdForUserThatDoesntExist_Returns404() { _fakeEditContactInfoViewModelBuilder.Setup(x => x.BuildAsync(It.IsAny <int>())).Returns(Task.FromResult(null as EditContactInfoViewModel)); ProfileController subject = _fixture.Create <ProfileController>(); ActionResult actionResult = await subject.EditContactInfo(123); AssertX.Is404NotFoundResult(actionResult); }
public void IndexerDataDeclaringTypeTest() { var t = typeof(TestClassDefinition); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); var indexer = typeData.GetMembers("Item")[0]; AssertX.Equal(typeData, indexer.ContainingType, "The DeclaringType of a member should be the type in which it is defined."); }
private static void AssertIsExactInstanceOfInner(Type expectedType, Exception actual, int retryCount) { if (actual.InnerException == null) AssertX.Fail("Retry Count {0}: Expected '{1}' be the inner exception, however, it is null.", retryCount, expectedType); Type actualType = actual.InnerException.GetType(); AssertX.Same(expectedType, actualType, "Retry Count {0}: Expected '{1}' to be the inner exception, however, '{2}' is.", retryCount, expectedType, actualType); }
private static void AssertIsExactInstanceOf(Type expectedType, Exception actual, int retryCount) { if (actual == null) AssertX.Fail("Retry Count {0}: Expected '{1}' to be thrown", retryCount, expectedType); Type actualType = actual.GetType(); AssertX.Same(expectedType, actualType, "Retry Count {0}: Expected '{1}' to be thrown, however, '{2}' was thrown.", retryCount, expectedType, actualType); }
public void SignIn_ReturnsAViewResult() { _fakeHttpContext.Setup(x => x.Request.IsAuthenticated).Returns(false); AccountController subject = _fixture.Create <AccountController>(); ActionResult actionResult = subject.SignIn(); AssertX.IsViewResult(actionResult); }
public void SignOut_RedirectsTheUserToTheSignInPageWithFlashMessage() { AccountController subject = _fixture.Create <AccountController>(); ActionResult actionResult = subject.SignOut(); AssertX.FlashMessageSet(subject, "info", "You have been signed out."); AssertX.IsRedirectToRouteResult(actionResult, MVC.Account.Name, MVC.Account.ActionNames.SignIn); }
public async Task Edit_GivenIdOfSkillThatDoesntExist_ReturnsHttpNotFound() { _fakeSkillManager.Setup(x => x.LoadByIdAsync(1)).Returns(Task.FromResult(null as Skill)); var subject = _fixture.Create <CanonicalSkillController>(); var actionResult = await subject.Edit(1); AssertX.Is404NotFoundResult(actionResult); }
public static GameObject GetChild(this GameObject source, string name) { var sourceName = source.name; return(AssertX.One <GameObject>( source.GetChildren(name), $"Expected exactly one child named '{name}' in game object named '{sourceName}'." )); }
public async Task Delete_GivenIdOfSkillThatDoesntExist_RedirectsToTheListPage() { _fakeSkillManager.Setup(x => x.LoadByIdAsync(456)).Returns(Task.FromResult(null as Skill)); var subject = _fixture.Create <CanonicalSkillController>(); var actionResult = await subject.Delete(456); AssertX.IsRedirectToRouteResult(actionResult, MVC.CanonicalSkill.Name, MVC.CanonicalSkill.ActionNames.List); }
public void IndexerDataNameTest() { var t = typeof(TestClassDefinition); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); var indexer = typeData.GetMembers("Item")[0]; AssertX.Equal("Item", indexer.Name, "The Name of the member is incorrect."); }
public async Task Add_GivenValidInput_RedirecstToTheListPageWithASuccessMessage() { var subject = _fixture.Create <CanonicalSkillController>(); var actionResult = await subject.Add(_validInput); AssertX.FlashMessageSet(subject, "success", "C# was added."); AssertX.IsRedirectToRouteResult(actionResult, MVC.CanonicalSkill.Name, MVC.CanonicalSkill.ActionNames.List); }
public void ImportingOneWhereMultipleArePresentFails() { var c = CreateContainer(typeof(LogA), typeof(LogB), typeof(UsesLog)); var x = AssertX.Throws <CompositionFailedException>(() => c.GetExport <UsesLog>()); Assert.IsTrue(x.Message.Contains("LogA")); Assert.IsTrue(x.Message.Contains("LogB")); }
public void MissingDependencyMessageIsInformative() { var cc = CreateContainer(typeof(UserOfUnregistered)); var x = AssertX.Throws <CompositionFailedException>(() => cc.GetExport <UserOfUnregistered>()); Assert.AreEqual("No export was found for the contract 'Unregistered'" + Environment.NewLine + " -> required by import 'Unregistered' of part 'UserOfUnregistered'" + Environment.NewLine + " -> required by initial request for contract 'UserOfUnregistered'", x.Message); }
public async Task EditContactInfo_GivenIdNotForCurrentUser_ReturnsUnauthorized() { SetLoggedInUserId(456); ProfileController subject = _fixture.Create <ProfileController>(); ActionResult actionResult = await subject.EditContactInfo(123); AssertX.IsRedirectToRestrictedPage(actionResult); }
public void CardinalityViolationMessageIsInformative() { var cc = CreateContainer(typeof(ShouldBeOne), typeof(ButThereIsAnother), typeof(RequiresOnlyOne)); var x = AssertX.Throws <CompositionFailedException>(() => cc.GetExport <RequiresOnlyOne>()); Assert.AreEqual("Only one export for the contract 'ShouldBeOne' is allowed, but the following parts: 'ButThereIsAnother', 'ShouldBeOne' export it." + Environment.NewLine + " -> required by import 'One' of part 'RequiresOnlyOne'" + Environment.NewLine + " -> required by initial request for contract 'RequiresOnlyOne'", x.Message); }
public void OperatorDataParametersTest() { var t = typeof(VariousMemberFeatures); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); var method = (OperatorData)typeData.GetMember("op_Addition"); AssertX.Equal(2, method.Parameters.Count, "The public method has the wrong number of parameters."); }
public void PropertyDataDeclaringTypeTest() { var t = typeof(VariousMemberFeatures); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); var member = (PropertyData)typeData.GetMember("PropertyReadOnly"); AssertX.Equal(typeData, member.ContainingType, "The DeclaringType of a member should be the type in which it is defined."); }
public void OperatorDataAccessibilityTest() { var t = typeof(VariousMemberFeatures); var context = MetadataResolutionContext.CreateFromTypes(t); var typeData = context.GetTypeDefinitionData(t); var member = typeData.GetMember("op_Addition"); AssertX.Equal(Accessibility.Public, member.Accessibility, "Incorrect Accessibility"); }