Ejemplo n.º 1
0
        public void Job_Test_Name_Must_Be_Unique()
        {
            var jobs = new List <Job>
            {
                new Job
                {
                    Name = "name"
                }
            };

            var mockDbSet = GetMockDbSet <Job>(jobs);

            var mockContext = new Mock <ZavenDotNetInterviewContext>();

            mockContext.Setup(c => c.Jobs).Returns(mockDbSet.Object);

            var jobValidator = new JobValidator(mockContext.Object);

            var isValid = jobValidator.IsValid(new Core.Models.CreateJobRequest
            {
                Name = "name"
            }, out var _);

            Assert.IsFalse(isValid);
        }
Ejemplo n.º 2
0
        public void Job_Test_DoAfter_Must_Be_Greater_Than_Datetime_Now()
        {
            var jobs      = new List <Job>();
            var mockDbSet = GetMockDbSet <Job>(jobs);

            var mockContext = new Mock <ZavenDotNetInterviewContext>();

            mockContext.Setup(c => c.Jobs).Returns(mockDbSet.Object);

            var jobValidator = new JobValidator(mockContext.Object);

            var isValid = jobValidator.IsValid(new Core.Models.CreateJobRequest
            {
                Name    = "name",
                DoAfter = DateTime.Now.AddDays(-1)
            }, out var _);

            Assert.IsFalse(isValid);
        }
Ejemplo n.º 3
0
        public void Job_Is_Correct()
        {
            var jobs      = new List <Job>();
            var mockDbSet = GetMockDbSet <Job>(jobs);

            var mockContext = new Mock <ZavenDotNetInterviewContext>();

            mockContext.Setup(c => c.Jobs).Returns(mockDbSet.Object);

            var jobValidator = new JobValidator(mockContext.Object);

            var isValid = jobValidator.IsValid(new Core.Models.CreateJobRequest
            {
                Name    = "Name",
                DoAfter = DateTime.Now.AddDays(1)
            }, out var _);

            Assert.IsTrue(isValid);
        }