示例#1
0
        public void AcceptFriend()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "InHarmonyTestLogicDB3")
                          .Options;

            using (var context = new ApplicationDbContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repository         _repository        = new Repository(context, _logger);
                BusinessLogicClass businessLogicClass = new BusinessLogicClass(_repository, _mapperClass, _logger);

                var user1 = new User {
                    UserName = "******"
                };
                var user2 = new User {
                    UserName = "******"
                };

                _repository.users.Add(user1);
                _repository.users.Add(user2);

                var fl = new FriendList {
                    FromUsername = user1.UserName, ToUsername = user2.UserName
                };
                _repository.friendList.Add(fl);
                context.SaveChanges();

                Assert.NotNull(businessLogicClass.AcceptFriend(fl));
                // Assert below is necessary to actually check if this is passing. Needs to be fixed in logic layer.
                // Assert.Equal("accept", fl.status);
            }
        }
 public async Task AcceptFriend(FriendList friend)
 {
     await _businessLogicClass.AcceptFriend(friend);
 }