Skip to content

Commit

Permalink
Solved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
94sedighi committed Dec 19, 2022
2 parents 14a7349 + c611a94 commit 4c13f74
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Src/FluentAssertions/Types/TypeSelector.cs
Expand Up @@ -201,6 +201,24 @@ public TypeSelector ThatAreNotAbstract()
return this;
}

/// <summary>
/// Filters and returns the types that are sealed
/// </summary>
public TypeSelector ThatAreSealed()
{
types = types.Where(t => t.IsSealed).ToList();
return this;
}

/// <summary>
/// Filters and returns the types that are not sealed
/// </summary>
public TypeSelector ThatAreNotSealed()
{
types = types.Where(t => !t.IsSealed).ToList();
return this;
}

/// <summary>
/// Filters and returns the types that are interfaces
/// </summary>
Expand Down
Expand Up @@ -2664,9 +2664,11 @@ namespace FluentAssertions.Types
public FluentAssertions.Types.TypeSelector ThatAreNotDecoratedWithOrInherit<TAttribute>()
where TAttribute : System.Attribute { }
public FluentAssertions.Types.TypeSelector ThatAreNotInNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreNotSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreNotInterfaces() { }
public FluentAssertions.Types.TypeSelector ThatAreNotStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreNotUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatDeriveFrom<TBase>() { }
Expand Down
Expand Up @@ -2794,9 +2794,11 @@ namespace FluentAssertions.Types
public FluentAssertions.Types.TypeSelector ThatAreNotDecoratedWithOrInherit<TAttribute>()
where TAttribute : System.Attribute { }
public FluentAssertions.Types.TypeSelector ThatAreNotInNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreNotSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreNotInterfaces() { }
public FluentAssertions.Types.TypeSelector ThatAreNotStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreNotUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatDeriveFrom<TBase>() { }
Expand Down
Expand Up @@ -2666,9 +2666,11 @@ namespace FluentAssertions.Types
public FluentAssertions.Types.TypeSelector ThatAreNotDecoratedWithOrInherit<TAttribute>()
where TAttribute : System.Attribute { }
public FluentAssertions.Types.TypeSelector ThatAreNotInNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreNotSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreNotInterfaces() { }
public FluentAssertions.Types.TypeSelector ThatAreNotStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreNotUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatDeriveFrom<TBase>() { }
Expand Down
Expand Up @@ -2666,9 +2666,11 @@ namespace FluentAssertions.Types
public FluentAssertions.Types.TypeSelector ThatAreNotDecoratedWithOrInherit<TAttribute>()
where TAttribute : System.Attribute { }
public FluentAssertions.Types.TypeSelector ThatAreNotInNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreNotSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreNotInterfaces() { }
public FluentAssertions.Types.TypeSelector ThatAreNotStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreNotUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatDeriveFrom<TBase>() { }
Expand Down
Expand Up @@ -2615,9 +2615,11 @@ namespace FluentAssertions.Types
public FluentAssertions.Types.TypeSelector ThatAreNotDecoratedWithOrInherit<TAttribute>()
where TAttribute : System.Attribute { }
public FluentAssertions.Types.TypeSelector ThatAreNotInNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreNotSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreNotInterfaces() { }
public FluentAssertions.Types.TypeSelector ThatAreNotStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreNotUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatDeriveFrom<TBase>() { }
Expand Down
Expand Up @@ -2666,9 +2666,11 @@ namespace FluentAssertions.Types
public FluentAssertions.Types.TypeSelector ThatAreNotDecoratedWithOrInherit<TAttribute>()
where TAttribute : System.Attribute { }
public FluentAssertions.Types.TypeSelector ThatAreNotInNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreNotSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreNotInterfaces() { }
public FluentAssertions.Types.TypeSelector ThatAreNotStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreNotUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatAreSealed() { }
public FluentAssertions.Types.TypeSelector ThatAreStatic() { }
public FluentAssertions.Types.TypeSelector ThatAreUnderNamespace(string @namespace) { }
public FluentAssertions.Types.TypeSelector ThatDeriveFrom<TBase>() { }
Expand Down
46 changes: 46 additions & 0 deletions Tests/FluentAssertions.Specs/Types/TypeSelectorSpecs.cs
Expand Up @@ -10,6 +10,7 @@
using Internal.NotOnlyClasses.Test;
using Internal.Other.Test;
using Internal.Other.Test.Common;
using Internal.SealedAndNotSealedClasses.Test;
using Internal.StaticAndNonStaticClasses.Test;
using Internal.UnwrapSelectorTestTypes.Test;
using Xunit;
Expand Down Expand Up @@ -530,6 +531,40 @@ public void When_selecting_types_that_are_not_abstract_classes_it_should_return_
.HaveCount(2);
}

[Fact]
public void When_selecting_types_that_are_sealed_classes_it_should_return_the_correct_types()
{
// Arrange
Assembly assembly = typeof(SealedClass).GetTypeInfo().Assembly;

// Act
IEnumerable<Type> types = AllTypes.From(assembly)
.ThatAreInNamespace("Internal.SealedAndNotSealedClasses.Test")
.ThatAreSealed();

// Assert
types.Should()
.ContainSingle()
.Which.Should().Be(typeof(SealedClass));
}

[Fact]
public void When_selecting_types_that_are_not_sealed_classes_it_should_return_the_correct_types()
{
// Arrange
Assembly assembly = typeof(NotSealedClass).GetTypeInfo().Assembly;

// Act
IEnumerable<Type> types = AllTypes.From(assembly)
.ThatAreInNamespace("Internal.SealedAndNotSealedClasses.Test")
.ThatAreNotSealed();

// Assert
types.Should()
.ContainSingle()
.Which.Should().Be(typeof(NotSealedClass));
}

[Fact]
public void When_selecting_types_that_are_static_classes_it_should_return_the_correct_types()
{
Expand Down Expand Up @@ -832,6 +867,17 @@ internal class ClassImplementingMultipleEnumerable : IEnumerable<int>, IEnumerab
}
}

namespace Internal.SealedAndNotSealedClasses.Test
{
internal sealed class SealedClass
{
}

internal class NotSealedClass
{
}
}

#pragma warning disable RCS1110 // Declare type inside namespace.
internal class ClassInGlobalNamespace { }
#pragma warning restore RCS1110
Expand Down
1 change: 1 addition & 0 deletions docs/_pages/releases.md
Expand Up @@ -11,6 +11,7 @@ sidebar:

### What's new
* Added `ThatAre[Not]Abstract` method for filtering the types - [#2058](https://github.com/fluentassertions/fluentassertions/pull/2058)
* Added `ThatAre[Not]Sealed` method for filtering the types - [#2059](https://github.com/fluentassertions/fluentassertions/pull/2059)
* Added `ThatAre[Not]Interfaces` method for filtering the types - [#2057](https://github.com/fluentassertions/fluentassertions/pull/2057)
* Added `ThatAre[Not]Abstract` methods to `MethodInfoSelector.cs` for filtering the methods - [#2060](https://github.com/fluentassertions/fluentassertions/pull/2060)
* Added `ThatAre[Not]Abstract`, `ThatAre[Not]Static` and `ThatAre[Not]Virtual` properties for filtering in `PropertyInfoSelector.cs` - [#2054](https://github.com/fluentassertions/fluentassertions/pull/2054)
Expand Down

0 comments on commit 4c13f74

Please sign in to comment.