Exemplo n.º 1
0
        public void Should_throw_exception_when_already_activated()
        {
            var language      = new Language();
            var command       = new ActivateLanguage();
            var validatorMock = new Mock <IValidator <ActivateLanguage> >();

            validatorMock.Setup(x => x.Validate(command)).Returns(new ValidationResult());

            language.Activate(command, validatorMock.Object);

            Assert.Throws <Exception>(() => language.Activate(command, validatorMock.Object));
        }
Exemplo n.º 2
0
        public void Should_set_language_status_to_activated()
        {
            var language      = new Language();
            var command       = new ActivateLanguage();
            var validatorMock = new Mock <IValidator <ActivateLanguage> >();

            validatorMock.Setup(x => x.Validate(command)).Returns(new ValidationResult());

            language.Activate(command, validatorMock.Object);

            Assert.AreEqual(true, language.Status == LanguageStatus.Active);
        }
Exemplo n.º 3
0
        public void Should_call_validator()
        {
            var language      = new Language();
            var command       = new ActivateLanguage();
            var validatorMock = new Mock <IValidator <ActivateLanguage> >();

            validatorMock.Setup(x => x.Validate(command)).Returns(new ValidationResult());

            language.Activate(command, validatorMock.Object);

            validatorMock.Verify(x => x.Validate(command));
        }
Exemplo n.º 4
0
        public void Should_set_site_id_in_language_activated_event()
        {
            var language      = new Language();
            var command       = new ActivateLanguage();
            var validatorMock = new Mock <IValidator <ActivateLanguage> >();

            validatorMock.Setup(x => x.Validate(command)).Returns(new ValidationResult());

            language.Activate(command, validatorMock.Object);

            var @event = language.Events.OfType <LanguageActivated>().SingleOrDefault();

            Assert.AreEqual(language.SiteId, @event.SiteId);
        }
Exemplo n.º 5
0
        public void Should_add_language_activated_event()
        {
            var language      = new Language();
            var command       = new ActivateLanguage();
            var validatorMock = new Mock <IValidator <ActivateLanguage> >();

            validatorMock.Setup(x => x.Validate(command)).Returns(new ValidationResult());

            language.Activate(command, validatorMock.Object);

            var @event = language.Events.OfType <LanguageActivated>().SingleOrDefault();

            Assert.IsNotNull(@event);
        }