Ejemplo n.º 1
0
        public void Should_return_false_when_InternalId_missing()
        {
            var builder = AccountCreated.CreateBuilder();

            builder
            .SetFirstName("1")
            .SetLastName("1")
            .SetEmailAddress("1")
            .SetExternalId("1");
            builder.AddPermissionSets("Star_Chef");
            var accountCreated = builder.Build();

            var validator = new AccountCreatedValidator(Mock.Of <IDatabaseCommands>());
            var actual    = validator.IsValidPayload(accountCreated);

            Assert.False(actual);
        }
Ejemplo n.º 2
0
        public void Should_catch_nonInt_IntenalId()
        {
            var        builder       = AccountCreated.CreateBuilder();
            const long MORE_THAN_INT = (((long)int.MaxValue) + 1);

            builder.SetExternalId("mandatory")
            .SetInternalId(MORE_THAN_INT.ToString());

            builder.AddPermissionSets("Star_Chef");
            builder.SetSource(Fourth.Orchestration.Model.Common.SourceSystemId.STARCHEF);
            var payload = builder.Build();

            var validator = new AccountCreatedValidator(Mock.Of <IDatabaseCommands>());
            var result    = validator.IsValidPayload(payload);

            Assert.False(result);
            Assert.Equal("InternalId is not Int32: " + MORE_THAN_INT, validator.GetErrors());
        }
Ejemplo n.º 3
0
        public void Should_catch_nonInt_IntenalId2()
        {
            var builder = AccountCreated.CreateBuilder();

            builder
            .SetInternalId("1sdsdsd")
            .SetUsername("1")
            .SetFirstName("1")
            .SetLastName("1")
            .SetEmailAddress("1")
            .SetExternalId("1");
            builder.AddPermissionSets("Star_Chef");
            builder.SetSource(Fourth.Orchestration.Model.Common.SourceSystemId.USER_MANAGEMENT);
            var payload = builder.Build();

            var validator = new AccountCreatedValidator(Mock.Of <IDatabaseCommands>());
            var result    = validator.IsValidPayload(payload);

            Assert.True(result);
            //Assert.Equal("InternalId is not Int32: " + MORE_THAN_INT, validator.GetErrors());
        }
Ejemplo n.º 4
0
        public void Should_return_false_when_PermissionSets_donot_contain_StarchefOrMenuCycle()
        {
            var builder = AccountCreated.CreateBuilder();

            builder
            .SetUsername("test")
            .SetInternalId("1")
            .SetFirstName("any")
            .SetLastName("any")
            .SetEmailAddress("any")
            .SetExternalId("any");

            builder.AddPermissionSets("Star_Char");

            var accountCreated = builder.Build();

            var validator = new AccountCreatedValidator(Mock.Of <IDatabaseCommands>());
            var actual    = validator.IsValidPayload(accountCreated);

            Assert.False(actual);
            Assert.Equal("PermissionSets don't contain Star_Chef or Menu_Cycles set.", validator.GetErrors());
        }
Ejemplo n.º 5
0
        public void Should_return_false_when_Username_too_long()
        {
            var       builder    = AccountCreated.CreateBuilder();
            const int MAX_LENGTH = 50;
            var       value      = Enumerable.Repeat("a", MAX_LENGTH + 1).Aggregate((a, b) => a + b);

            builder
            .SetUsername(value)
            .SetInternalId("1")
            .SetFirstName("any")
            .SetLastName("any")
            .SetEmailAddress("any")
            .SetExternalId("any");
            builder.AddPermissionSets("Star_Chef");
            var accountCreated = builder.Build();

            var validator = new AccountCreatedValidator(Mock.Of <IDatabaseCommands>());
            var actual    = validator.IsValidPayload(accountCreated);

            Assert.False(actual);
            Assert.Equal("Username exceeds the maximum length of 50 characters.", validator.GetErrors());
        }