public void ServerCheckResults_Is_OK_When_OneEntry11HoursOld_is_InTheDatabase() { //assemble string servername = "Server"; DataTable serverInformation = MakeServerInformationTable(); DataRow dr; dr = serverInformation.NewRow(); // older measurement dr["ServerName"] = servername; dr["CollectionTime"] = DateTime.Now.Subtract(TimeSpan.FromHours(11)); dr["Measurement"] = 100; serverInformation.Rows.Add(dr); //act ServerConfiguration expected = ServerConfiguration.OK; ServerCheck target = new ServerCheck(serverInformation); //act ServerConfiguration actual = target.Result(servername); //assert Assert.AreEqual(expected, actual); }
public void ServerCheckResults_Is_OK_When_ItsARecentMeasurementAndChange_is_LessThan15Percent() { //assemble string servername = "Server"; DataTable serverInformation = MakeServerInformationTable(); DataRow dr; dr = serverInformation.NewRow(); // older measurement dr["ServerName"] = servername; dr["CollectionTime"] = DateTime.Now.Subtract(TimeSpan.FromHours(13)); dr["Measurement"] = 100; serverInformation.Rows.Add(dr); dr = serverInformation.NewRow(); dr["ServerName"] = servername; dr["CollectionTime"] = DateTime.Now.Subtract(TimeSpan.FromHours(2)); dr["Measurement"] = 114; serverInformation.Rows.Add(dr); ServerConfiguration expected = ServerConfiguration.OK; ServerCheck target = new ServerCheck(serverInformation); //act ServerConfiguration actual = target.Result(servername); //assert Assert.AreEqual(expected, actual); }
public void ServerConfigurationResult_Is_ReportingError_When_LastDBEntry_is_MoreThan12HoursOld() { //assemble string servername = "Server"; DataTable serverInformation = MakeServerInformationTable(); DataRow dr; dr = serverInformation.NewRow(); dr["ServerName"] = string.Concat(servername); dr["CollectionTime"] = DateTime.Now.Subtract(TimeSpan.FromHours(13)); dr["Measurement"] = 0; serverInformation.Rows.Add(dr); ServerConfiguration expected = ServerConfiguration.ReportingError; ServerCheck target = new ServerCheck(serverInformation); //act ServerConfiguration actual = target.Result(servername); //assert Assert.AreEqual(expected, actual); }
public void ServerConfigurationResult_Is_Error_When_ServerName_is_NotFoundinDB() { //assemble string servername = "Server"; DataTable table = MakeServerInformationTable(); DataRow dr; dr = table.NewRow(); dr["ServerName"] = string.Concat(servername); dr["CollectionTime"] = DateTime.Now; dr["Measurement"] = 0; table.Rows.Add(dr); ServerConfiguration expected = ServerConfiguration.Error; ServerCheck target = new ServerCheck(table); //act ServerConfiguration actual = target.Result(string.Concat(servername, "A")); //assert Assert.AreEqual(expected, actual); }