public SetCharacterNameAsync() { var mockedUserObject = MockHelper.CreateDiscordGuildUser(0); var mockedGuild = new Mock <IGuild>(); mockedGuild.Setup(g => g.Id).Returns(1); mockedGuild.Setup ( c => c.GetUserAsync ( It.IsAny <ulong>(), CacheMode.AllowDownload, null ) ) .Returns(Task.FromResult(mockedUserObject)); var mockedGuildObject = mockedGuild.Object; var mockedContext = new Mock <ICommandContext>(); mockedContext.Setup(c => c.User).Returns(mockedUserObject); mockedContext.Setup(c => c.Guild).Returns(mockedGuildObject); var mockedMessage = new Mock <IUserMessage>(); mockedMessage.Setup(m => m.Author).Returns(mockedUserObject); mockedContext.Setup(c => c.Message).Returns(mockedMessage.Object); _context = mockedContext.Object; _character = new Character ( (long)mockedGuildObject.Id, new User((long)mockedUserObject.Id), CharacterName ); var anotherCharacter = new Character ( (long)mockedGuildObject.Id, new User((long)mockedUserObject.Id), AnotherCharacterName ); this.Database.Characters.Update(_character); this.Database.Characters.Update(anotherCharacter); this.Database.SaveChanges(); }