Esempio n. 1
0
        public async void ToUserId_Create_Invalid_Reference()
        {
            Mock <IMessengerRepository> messengerRepository = new Mock <IMessengerRepository>();

            messengerRepository.Setup(x => x.UserByToUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(null));

            var validator = new ApiMessengerServerRequestModelValidator(messengerRepository.Object);

            await validator.ValidateCreateAsync(new ApiMessengerServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.ToUserId, 1);
        }
Esempio n. 2
0
        public async void MessageId_Update_Invalid_Reference()
        {
            Mock <IMessengerRepository> messengerRepository = new Mock <IMessengerRepository>();

            messengerRepository.Setup(x => x.MessageByMessageId(It.IsAny <int>())).Returns(Task.FromResult <Message>(null));

            var validator = new ApiMessengerServerRequestModelValidator(messengerRepository.Object);

            await validator.ValidateUpdateAsync(default(int), new ApiMessengerServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.MessageId, 1);
        }