Ejemplo n.º 1
0
        public void Equality()
        {
            var acl1 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl2 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl3 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a2",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };

            var ex1 = new DeleteAclsException(new List <DeleteAclsReport>());
            var ex2 = new DeleteAclsException(new List <DeleteAclsReport>
            {
                new DeleteAclsReport()
                {
                    Error       = new Error(ErrorCode.NoError, "Success", false),
                    AclBindings = new List <AclBinding>
                    {
                        acl1,
                        acl2
                    }
                }
            });
            var ex3 = new DeleteAclsException(new List <DeleteAclsReport>
            {
                new DeleteAclsReport()
                {
                    Error       = new Error(ErrorCode.NoError, "Other message", false),
                    AclBindings = new List <AclBinding>
                    {
                        acl2.Clone(),
                        acl1.Clone(),
                        acl1.Clone(),
                    }
                }
            });
            var ex4 = new DeleteAclsException(new List <DeleteAclsReport>
            {
                new DeleteAclsReport()
                {
                    Error       = new Error(ErrorCode.NoError, "Other message", false),
                    AclBindings = new List <AclBinding>
                    {
                        acl1.Clone(),
                        acl2.Clone(),
                        acl3.Clone(),
                    }
                }
            });

            Assert.NotEqual(ex1, ex2);
            Assert.True(ex1 != ex2);
            Assert.Equal(ex2, ex3);
            Assert.True(ex2 == ex3);
            Assert.NotEqual(ex3, ex4);
            Assert.True(ex3 != ex4);
        }
Ejemplo n.º 2
0
        public void Equality()
        {
            var acl1 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl2 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };

            var rep1 = new DescribeAclsReport {
            };
            var rep2 = new DescribeAclsReport {
            };
            var rep3 = new DescribeAclsReport
            {
                Error = new Error(ErrorCode.NoError, "Success", false),
            };
            var rep4 = new DescribeAclsReport
            {
                Error       = new Error(ErrorCode.NoError, "Success", false),
                AclBindings = new List <AclBinding>
                {
                    acl1,
                    acl2
                }
            };
            var rep5 = new DescribeAclsReport
            {
                Error       = rep4.Error,
                AclBindings = rep4.AclBindings
            };
            var rep6 = new DescribeAclsReport
            {
                Error       = new Error(ErrorCode.NoError, "Other message", false),
                AclBindings = new List <AclBinding>
                {
                    acl1.Clone(),
                acl2.Clone()
                }
            };
            var rep7 = new DescribeAclsReport
            {
                Error       = new Error(ErrorCode.NoError, "Success", true),
                AclBindings = new List <AclBinding>
                {
                    acl1.Clone(),
                acl2.Clone()
                }
            };

            Assert.Equal(rep1, rep2);
            Assert.True(rep1 == rep2);
            Assert.NotEqual(rep1, rep3);
            Assert.False(rep1 == rep3);
            Assert.NotEqual(rep3, rep4);
            Assert.True(rep3 != rep4);
            Assert.Equal(rep4, rep5);
            Assert.True(rep4 == rep5);
            Assert.Equal(rep4, rep6);
            Assert.True(rep4 == rep6);
            Assert.NotEqual(rep6, rep7);
            Assert.True(rep6 != rep7);
        }
        public void Equality()
        {
            var acl1 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = null,
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = null,
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };
            var acl2 = new AclBinding
            {
                Pattern = new ResourcePattern
                {
                    Type = ResourceType.Topic,
                    Name = "a1",
                    ResourcePatternType = ResourcePatternType.Literal
                },
                Entry = new AccessControlEntry
                {
                    Principal      = "p1",
                    Host           = "h1",
                    Operation      = AclOperation.All,
                    PermissionType = AclPermissionType.Allow
                }
            };

            var res1 = new DescribeAclsResult {
            };
            var res2 = new DescribeAclsResult {
            };
            var res3 = new DescribeAclsResult
            {
                AclBindings = new List <AclBinding>
                {
                    acl1,
                    acl2
                }
            };
            var res4 = new DescribeAclsResult
            {
                AclBindings = res3.AclBindings
            };
            var res5 = new DescribeAclsResult
            {
                AclBindings = new List <AclBinding>
                {
                    acl1.Clone(),
                acl2.Clone()
                }
            };

            Assert.Equal(res1, res2);
            Assert.True(res1 == res2);
            Assert.Equal(res3, res4);
            Assert.True(res3 == res4);
            Assert.Equal(res3, res5);
            Assert.True(res3 == res5);
        }