public void GetAutoUpdateUsers() { string[] users = new[] { "user1", "user2" }; _userServiceMock.ExpectAndReturn("GetAutoUpdateUsers", users); IEnumerable <string> userIds = _manager.GetAutoUpdateUsers(); Assert.That(userIds, Is.Not.Null.Or.Empty); Assert.That(String.Join(", ", userIds), Is.EquivalentTo("user1, user2")); _userServiceMock.Verify(); }
public void GetAutoUpdateUsers() { User[] expectedUsers = new[] { new User { SteamUserId = "user1" }, new User { SteamUserId = "user2" } }; _userServiceMock.Setup(service => service.GetAutoUpdateUsers()) .Returns(expectedUsers) .Verifiable(); ICollection <User> users = _manager.GetAutoUpdateUsers(); Assert.That(users, Is.Not.Null.Or.Empty); Assert.That(users.Count, Is.EqualTo(2)); _userServiceMock.Verify(); }
public void ProcessRequest(HttpContext context) { try { string logPath = context.Server.MapPath("~/App_Data/AutoUpdate"); _log = new AutoUpdateLogger(logPath); IUnityContainer container = ContainerManager.Container; _manager = new AutoUpdateManager(container.Resolve <IAchievementService>(), container.Resolve <IUserService>(), container.Resolve <IFacebookPublisher>(), _log); bool authorized = context.Request["auth"] == Properties.Settings.Default.AutoUpdateAuthKey; if (!authorized) { _log.Log("Invalid auth key"); context.Response.Write("Invalid auth key"); } else { string method = context.Request["method"]; if (method == "GetAutoUpdateUsers") { _log.Log("Getting auto update users"); string users = _manager.GetAutoUpdateUsers(); _log.Log(users); _log.Flush(); context.Response.Write(users); } else if (method == "PublishUserAchievements") { string userName = context.Request["user"]; _manager.PublishUserAchievements(userName); _log.Flush(); context.Response.Write(userName + " published."); // delete logs more than two weeks old _log.Delete(DateTime.UtcNow.AddDays(-14).Date); } else { context.Response.Write("Invalid method"); } } } catch (Exception ex) { _log.Log(ex); _log.Write(context.Response); } finally { _manager.Dispose(); _log.Flush(); } }