public async void ToUserId_Create_Valid_Reference() { Mock <IMessengerRepository> messengerRepository = new Mock <IMessengerRepository>(); messengerRepository.Setup(x => x.UserByToUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(new User())); var validator = new ApiMessengerServerRequestModelValidator(messengerRepository.Object); await validator.ValidateCreateAsync(new ApiMessengerServerRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.ToUserId, 1); }
public async void MessageId_Create_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.ValidateCreateAsync(new ApiMessengerServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.MessageId, 1); }