J'ai méthode vide:Définir nom de variable après l'exécution de la méthode dans le test Unité
this._dispatcher.PushAsync(handler, cmd);
Après l'exécution, j'ai changé propriété de cmd
:
cmd.Result = userId;
Comment puis-je mettre en valeur de la propriété après la méthode d'exécution vide en test unitaire?
J'essaie quelque chose comme ça:
_dispatcher = new Mock<IDispatcher>();
_a = new Mock<SaveUserCmd>();
_dispatcher
.Setup(r => r.PushAsync(_cmdHandler, this._cmd))
.Callback(() => _a.SetupProperty(y => y.Result == this._response));
Mais il montre ...
(Error: Expression is not a property access:
y => y.Result == this._response
).
SaveUserCmd:
public class SaveUserCmd
{
public string FirstName { get; set; }
public string LastName { get; set; }
public object Result { get; set; }
}
IDispatcher:
public interface IDispatcher
{
Task PushAsync<TCommand>(ICommandHandlerAsync<TCommand> commandHandlerAsync, TCommand message);
}
Qu'est-ce que "is whrong" signifie? Toute exception? Comportement inattendu – HimBromBeere