Exemplo n.º 1
0
        public ActionResult <string> PostTopSecret(dynamic data)
        {
            try
            {
                //Request and Response data definitions
                string                requestData            = data.ToString();
                string                responseData           = "";
                AllSatellitesData     satellitesInformation  = JsonConvert.DeserializeObject <AllSatellitesData>(requestData);
                TopSecretResponseData topSecretResponsetData = imperialSniffer.GetImperialShipInformation(satellitesInformation);

                responseData = JsonConvert.SerializeObject(topSecretResponsetData);
                return(responseData);
            }
            catch (Exception ex)
            {
                //TODO: Log exception Message.
                return(NotFound());
            }
        }
        public override async Task <AllSatellitesData> GetListOfValidatedSatellitesData()
        {
            AllSatellitesData allSatellitesData = new AllSatellitesData();

            //Here I should ask for the information received from every satellite which has actually received a message
            List <TopSecretSplitItem> topSecretSplitItems = _context.TopSecretSplitItems.ToList(); //At this moment I get all the table because I have only one Imperial Ship to track. But it could be asked as a Query with some particular request (i.e: name of imperial Ship).

            //Here I should validate Date and Time from the last 3 messages.
            ValidateSatellitesData(topSecretSplitItems);

            foreach (TopSecretSplitItem item in topSecretSplitItems)
            {
                //Split the message string that came from the DB message, it was merge in one single string in order to be saved in one register.
                List <string> wordsOfMessage = new List <string>(item.message.Split(_wordsSeparator));

                SatelliteData satellitData = new SatelliteData(item.name, item.distance, wordsOfMessage);
                allSatellitesData.satellites.Add(satellitData);
            }

            return(allSatellitesData);
        }
Exemplo n.º 3
0
        public void GetLocationTestOK()
        {
            //parameters
            AllSatellitesData allSatellitesData = new AllSatellitesData();

            allSatellitesData.satellites.Add(new SatelliteData("kenobi", 583, new List <string>(new string[] { "este", "", "", "mensaje", "" })));
            allSatellitesData.satellites.Add(new SatelliteData("skywalker", 223, new List <string>(new string[] { "", "es", "", "", "secreto" })));
            allSatellitesData.satellites.Add(new SatelliteData("sato", 500, new List <string>(new string[] { "este", "", "un", "", "" })));
            float locationXexpected = (float)0.4;
            float locationYexpected = (float)98.6;

            // Act
            ShipLocator   shipLocator = new ShipLocator();
            XYCoordinates location    = shipLocator.GetLocation(allSatellitesData);


            // Assert
            Assert.AreEqual(locationXexpected, location.GetCoordinateX());
            Assert.AreEqual(locationYexpected, location.GetCoordinateY());
            Assert.Pass();
        }
Exemplo n.º 4
0
        public virtual async Task <AllSatellitesData> GetListOfValidatedSatellitesData()
        {
            AllSatellitesData allSatellitesData = new AllSatellitesData();

            return(allSatellitesData);
        }