public virtual void PublishContestWithIncorrectBaselineResultsTest()
        {
            //authenticate with valid credentials
            AuthenticationResponse authenticationResponse = AuthenticateSync(ValidCredentials);

            //check if authentication succeed
            Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, authenticationResponse.Status);

            //create dummy contest
            var dummyContest = CreateDummyContest("PublishContestWithIncorrectBaselineResultsTest");

            //create dummy contest results that are incorrect (they do not match contest metric definitions)
            var seriesMetric   = MockContestResultsHelper.CreateDummySeriesMetricResults("Not matching series metric name", "Some description");
            var boxMetric      = MockContestResultsHelper.CreateDummyBoxSummaryMetricResults("Not matchin box metric name", "Some description");
            var resultDataset1 = CreateDummyResultsDTO("Dataset 1", seriesMetric, boxMetric); //the name of metric won't match with metric definitions in the contest
            var allResults     = new List <DatasetResultsDTO>()
            {
                resultDataset1
            };

            Random         random         = new Random();
            double         score          = random.NextDouble();
            ContestResults contestResults = new ContestResults(dummyContest.ContestGUID, "Baseline", "Baseline technique description", allResults, score, FakeBaseData);

            dummyContest.BaselineResults = contestResults;

            //the authentication provides the ticket necessary to publish the contest
            ContestPublishedResponse response = PublishContestSync(authenticationResponse.Ticket, ValidCredentials.Username, dummyContest);

            Assert.AreEqual(ResponseStatus.STATUS_FAILURE, response.Status);
            Assert.IsNotNull(response.ErrorMessage);
            Assert.AreEqual("Baseline results failed to be saved. Metric results does not match metrics defined in the contest.", response.ErrorMessage);
        }
        public void Setup()
        {
            //create mock box line series metric
            LineSeriesMetric = MockContestResultsHelper.CreateDummySeriesMetricResults(m_mockSeriesMetricName, "Mock series metric description");

            //create mock box summary metric
            BoxSummaryMetric = MockContestResultsHelper.CreateDummyBoxSummaryMetricResults(m_mockBoxPlotMetricName, "Mock box plot metric description");

            DummyCorrectResults = GenerateDummyResults(LineSeriesMetric, BoxSummaryMetric);

            FakeBaseData = MockContestResultsHelper.CreateDummyBaseData();
        }
        public virtual void PublishContestResultTest()
        {
            //authenticate with valid credentials
            AuthenticationResponse authenticationResponse = AuthenticateSync(ValidCredentials);

            //check if authentication succeed
            Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, authenticationResponse.Status);

            //create dummy contest
            var dummyContest = CreateDummyContest("PublishContestResultTest");

            //the authentication provides the ticket necessary to publish the contest
            ContestPublishedResponse response = PublishContestSync(authenticationResponse.Ticket, ValidCredentials.Username, dummyContest);

            Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, response.Status);

            //once the contest is published test publishing contest results

            Random         random         = new Random();
            double         score          = random.NextDouble();
            ContestResults contestResults = new ContestResults(dummyContest.ContestGUID,
                                                               "Mock technique", "Mock technique description", DummyCorrectResults, score, FakeBaseData);

            //reuse the same ticket and valid credentials...
            //typically it would be another user, but it doesn't matter for test purposes (it may be so the contest creator also publishes results)
            ContestResultsPublishedResponse resultPublishedResponse = PublishContestResultSync(authenticationResponse.Ticket, ValidCredentials.Username, contestResults);

            Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, resultPublishedResponse.Status);
            Assert.IsNull(resultPublishedResponse.ErrorMessage);

            //create other set of results for the same metrics
            var lineSeriesMetric    = MockContestResultsHelper.CreateDummySeriesMetricResults(m_mockSeriesMetricName, "Mock series metric description");
            var boxSummaryMetric    = MockContestResultsHelper.CreateDummyBoxSummaryMetricResults(m_mockBoxPlotMetricName, "Mock box plot metric description");
            var otherCorrectResults = GenerateDummyResults(lineSeriesMetric, boxSummaryMetric);

            score                   = random.NextDouble();
            contestResults          = new ContestResults(dummyContest.ContestGUID, "Another technique", "Another technique description", otherCorrectResults, score, FakeBaseData);
            resultPublishedResponse = PublishContestResultSync(authenticationResponse.Ticket, ValidCredentials.Username, contestResults);

            Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, resultPublishedResponse.Status);
            Assert.IsNull(resultPublishedResponse.ErrorMessage);
            Assert.IsNotNull(resultPublishedResponse.ContestWebsiteLink);
        }
        public virtual void PublishNotMatchingContestResultTest()
        {
            //authenticate with valid credentials
            AuthenticationResponse authenticationResponse = AuthenticateSync(ValidCredentials);

            //check if authentication succeed
            Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, authenticationResponse.Status);

            //create dummy contest
            var dummyContest = CreateDummyContest("PublishNotMatchingContestResultTest");

            //the authentication provides the ticket necessary to publish the contest
            ContestPublishedResponse response = PublishContestSync(authenticationResponse.Ticket, ValidCredentials.Username, dummyContest);

            Assert.AreEqual(ResponseStatus.STATUS_SUCCESS, response.Status);

            //once the contest is published test publishing contest results

            //create dummy contest results, that have metric that does not match contest metric definitions
            var seriesMetric   = MockContestResultsHelper.CreateDummySeriesMetricResults("Not matching series metric name", "Some description");
            var boxMetric      = MockContestResultsHelper.CreateDummyBoxSummaryMetricResults("Not matchin box metric name", "Some description");
            var resultDataset1 = CreateDummyResultsDTO("Dataset 1", seriesMetric, boxMetric); //the name of metric won't match with metric definitions in the contest
            var allResults     = new List <DatasetResultsDTO>()
            {
                resultDataset1
            };

            Random         random         = new Random();
            double         score          = random.NextDouble();
            ContestResults contestResults = new ContestResults(dummyContest.ContestGUID, "Mock technique", "Mock technique description", allResults, score, FakeBaseData);

            //reuse the same ticket and valid credentials...
            //typically it would be another user, but it doesn't matter for test purposes (it may be so the contest creator also publishes results)
            ContestResultsPublishedResponse resultPublishedResponse = PublishContestResultSync(authenticationResponse.Ticket, ValidCredentials.Username, contestResults);

            //cannot publish empty results
            Assert.AreEqual(ResponseStatus.STATUS_FAILURE, resultPublishedResponse.Status);
            Assert.IsNotNull(resultPublishedResponse.ErrorMessage);
            Assert.AreEqual("Metric results does not match metrics defined in the contest.", resultPublishedResponse.ErrorMessage);
        }
 private static DatasetResultsDTO CreateDummyResultsDTO(string datasetName,
                                                        TraceLabSDK.Types.Contests.LineSeries lineSeriesMetric,
                                                        TraceLabSDK.Types.Contests.BoxSummaryData boxSummaryMetric)
 {
     return(new DatasetResultsDTO(MockContestResultsHelper.CreateDummyDatasetResults(datasetName, lineSeriesMetric, boxSummaryMetric)));
 }