/// <summary>
        /// Find a wrap in this collection that
        /// is either on holiday or not depending on argument
        /// </summary>
        /// <param name="argument">
        /// true is on holiday, false is not on holiday
        /// </param>
        /// <returns>a wrap that meets the criteria or null if no match</returns>
        private IWrap FindWrapByOnHoliday(bool argument)
        {
            var retVal = default(IWrap);

            var wrapElements = WebAdapter.FindElements(By.Id("lin_wrap"));

            if (wrapElements == null)
            {
                return(null);
            }

            // Loop through all the items in the collection until
            // find one whose OnHoliday status matches the argument
            var numberOfWraps = wrapElements.Count;

            for (var i = 1; i <= numberOfWraps; i++)
            {
                var xpath       = $"(//a[@id='lin_wrap'])[{i}]";
                var element     = WebAdapter.FindElement(By.XPath(xpath));
                var linWrapText = element.Text;
                var wtApi       = Get <IWtApi>();
                var wrapInfo    = wtApi.WrapInfoByTrackId(linWrapText);

                if (wrapInfo.OnHoliday == argument)
                {
                    element.Click();
                    retVal = StfContainer.Get <IWrap>();
                    break;
                }
            }

            return(retVal);
        }
        /// <summary>
        /// Returns random wrap in collection.
        /// </summary>
        /// <param name="wtIdContraint">
        /// Constrain the randomness to NOT return this wrap
        /// </param>
        /// <returns>
        /// The <see cref="IWrap"/>.
        /// </returns>
        public IWrap GetRandomWrap(string wtIdContraint = null)
        {
            var wrapElements  = WebAdapter.FindElements(By.Id("lin_wrap"));
            var numberOfWraps = wrapElements.Count;
            var random        = new Random();
            var wrapToChoose  = random.Next(1, numberOfWraps + 1);
            var xpath         = $"(//a[@id='lin_wrap'])[{wrapToChoose}]";
            var element       = WebAdapter.FindElement(By.XPath(xpath));
            var linWrapText   = element.Text;

            if (!string.IsNullOrEmpty(wtIdContraint) &&
                numberOfWraps > 1 &&
                linWrapText.Equals(wtIdContraint, StringComparison.CurrentCultureIgnoreCase))
            {
                wrapToChoose = wrapToChoose == numberOfWraps ? 1 : wrapToChoose + 1;
                xpath        = $"(//a[@id='lin_wrap'])[{wrapToChoose}]";
                element      = WebAdapter.FindElement(By.XPath(xpath));
            }

            StfLogger.LogInfo($"We choose wrap number {wrapToChoose} (of {numberOfWraps}) - {linWrapText}");
            element.Click();

            var retVal = StfContainer.Get <IWrap>();

            return(retVal);
        }
Beispiel #3
0
        /// <summary>
        /// Finds users collection
        /// </summary>
        /// <returns>
        /// NULL if user has no wraps in collection
        /// </returns>
        public ICollection GetCollection()
        {
            WebAdapter.ButtonClickById("nav_collection");

            var retVal = StfContainer.Get <ICollection>();

            return(retVal);
        }
        /// <summary>
        /// The explorer.
        /// </summary>
        /// <returns>
        /// The <see cref="IExplore"/>.
        /// </returns>
        public IExplore Explore()
        {
            var clicked = WebAdapter.ButtonClickById("nav_explore");
            var retVal  = clicked
                       ? StfContainer.Get <IExplore>()
                       : null;

            return(retVal);
        }
        /// <summary>
        /// The news.
        /// </summary>
        /// <returns>
        /// The <see cref="INews"/>.
        /// </returns>
        public INews News()
        {
            var clicked = WebAdapter.ButtonClickById("nav_home");
            var retVal  = clicked
                       ? StfContainer.Get <INews>()
                       : null;

            return(retVal);
        }
        /// <summary>
        /// The collection.
        /// </summary>
        /// <returns>
        /// The <see cref="ICollection"/>.
        /// </returns>
        public ICollection Collection()
        {
            var but = WebAdapter.FindElement(By.Id("## MISSING ##"));

            but.Click();

            var retVal = StfContainer.Get <ICollection>();

            return(retVal);
        }
Beispiel #7
0
        /// <summary>
        /// The learn more.
        /// </summary>
        /// <returns>
        /// The <see cref="ILearnMore"/>.
        /// </returns>
        public ILearnMore LearnMore()
        {
            // Press learn more
            var but = WebAdapter.FindElement(By.Id("LearnMore"));

            but.Click();

            var retVal = StfContainer.Get <ILearnMore>();

            return(retVal);
        }
        /// <summary>
        /// The get to model.
        /// </summary>
        /// <param name="modelId">
        /// The model id.
        /// </param>
        /// <returns>
        /// The <see cref="IModel"/>.
        /// </returns>
        public IModel GetToModel(string modelId)
        {
            var baseUrl    = WtConfiguration.Url;
            var modelIdUrl = $"{baseUrl}Catalog/model/{modelId}";

            WebAdapter.OpenUrl(modelIdUrl);

            var retVal = StfContainer.Get <IModel>();

            return(retVal);
        }
Beispiel #9
0
        /// <summary>
        /// The init.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Init()
        {
            // register my needed types
            StfContainer.RegisterType <ILearnMore, LearnMore>();

            // get what I need - a WebAdapter:-)
            WebAdapter = StfContainer.Get <IWebAdapter>();

            WebAdapter.OpenUrl("http://democorpweb.azurewebsites.net/");

            return(true);
        }
        /// <summary>
        /// The get to wrap.
        /// </summary>
        /// <param name="wrapId">
        /// The wrap id.
        /// </param>
        /// <returns>
        /// The <see cref="IWrap"/>.
        /// </returns>
        public IWrap GetToWrap(string wrapId)
        {
            var baseUrl   = WtConfiguration.Url;
            var wrapIdUrl = $"{baseUrl}Collection/wrap/{wrapId}";
            var openUrl   = WebAdapter.OpenUrl(wrapIdUrl);

            if (!openUrl)
            {
                StfLogger.LogError($"Couldn't open the url [{wrapIdUrl}]");
                return(null);
            }

            var retVal = StfContainer.Get <IWrap>();

            return(retVal);
        }
        /// <summary>
        /// The init.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Init()
        {
            var registerMyNeededTypes = new RegisterMyNeededTypes(this);

            registerMyNeededTypes.Register();
            WtConfiguration = SetConfig <WtConfiguration>();

            // get what I need - a WebAdapter:-)
            WebAdapter = StfContainer.Get <IWebAdapter>();

            WebAdapter.OpenUrl(WtConfiguration.Url);

            var currentDomainBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            StfLogger.LogKeyValue("Current Directory", currentDomainBaseDirectory, "Current Directory");
            return(true);
        }
        /// <summary>
        /// The init.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Init()
        {
            try
            {
                StfContainer.RegisterType <ITestPluginModel, TestPluginModel>();
                StfContainer.RegisterType <ITestPluginModel2, TestPluginModel2>();
                StfContainer.RegisterType <ITestPluginAdapter, TestPluginAdapter>();
                StfContainer.RegisterType <TestPluginTypeWithoutInterface>();
                StfContainer.RegisterType <TestAdapterWithoutInterface>();
                StfContainer.RegisterType <IStfSingletonPluginType, StfSingletonPluginType>();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Beispiel #13
0
        /// <summary>
        /// The init.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Init()
        {
            // register my needed types
            StfContainer.RegisterType <ICollection, Collection>();
            StfContainer.RegisterType <IMe, Me.Me>();
            StfContainer.RegisterType <IExplorer, Explorer>();
            StfContainer.RegisterType <IFaq, Faq.Faq>();

            // get what I need - a WebAdapter:-)
            WebAdapter = StfContainer.Get <IWebAdapter>();
            WebAdapter.OpenUrl("http://WrapTrack.org/");

            var currentDomainBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            StfLogger.LogKeyValue("Current Directory", currentDomainBaseDirectory, "Current Directory");
            Login("ida88", "lk8dsafpUqwe");

            return(true);
        }
Beispiel #14
0
        /// <summary>
        /// Get the web adapter configuration
        /// </summary>
        /// <returns>
        /// Instance of web adapter configuration
        /// </returns>
        private WebAdapterConfiguration GetConfiguration()
        {
            WebAdapterConfiguration retVal;

            try
            {
                var stfConfiguration = StfContainer.Get <StfConfiguration>();

                retVal = new WebAdapterConfiguration();

                stfConfiguration.LoadUserConfiguration(retVal);
            }
            catch (Exception ex)
            {
                StfLogger.LogInternal($"Couldn't GetConfiguration - got error [{ex.Message}]");
                retVal = null;
            }

            return(retVal);
        }
        /// <summary>
        /// The me.
        /// </summary>
        /// <returns>
        /// The <see cref="IMeProfile"/>.
        /// </returns>
        public IMeProfile Me()
        {
            // press the top menu tab
            var buttonClicked = WebAdapter.ButtonClickById("nav_me");

            if (!buttonClicked)
            {
                return(null);
            }

            // when number of wraps is high, the rendering might take some time...
            // TODO: Implement using Selenium Waiter
            WebAdapter.WaitForComplete(5);

            // press the second level top menu tab - called "profile"
            buttonClicked = WebAdapter.ButtonClickById("nav_profile");

            var retVal = buttonClicked
                ? StfContainer.Get <IMeProfile>()
                : null;

            return(retVal);
        }
Beispiel #16
0
            public StfFile(Stream stream, string filename, OpenRA.FileSystem.FileSystem filesystem)
            {
                this.stream = stream;
                Name        = filename;
                var container = new StfContainer(stream);

                index = container.Files;
                contents.AddRange(index.Keys);
                Stream remapStream;

                if (!filesystem.TryOpen(filename + ".yaml", out remapStream))
                {
                    return;
                }
                var remapYaml = MiniYaml.FromStream(remapStream);
                var aniLoader = new AniLoader();

                foreach (var entry in remapYaml)
                {
                    var targetAni    = entry.Key;
                    var targetFrames = new List <AniLoader.AniSpriteFrame>();

                    foreach (var set in entry.Value.Value.Split(' '))
                    {
                        var            flipX       = set.Contains("x");
                        var            flipY       = set.Contains("y");
                        var            sourceParts = set.Replace("x", "").Replace("y", "").Split(':');
                        ISpriteFrame[] sourceFrames;
                        aniLoader.TryParseSprite(GetStream(sourceParts[0] + ".ani"), out sourceFrames);

                        var targetFramesList = new List <int>();

                        if (sourceParts[1].Contains("-"))
                        {
                            var rangeParts = sourceParts[1].Split('-');
                            var from       = int.Parse(rangeParts[0]);
                            var to         = rangeParts.Length > 1 ? int.Parse(rangeParts[1]) : from;

                            if (from < to)
                            {
                                for (var i = from; i <= to; i++)
                                {
                                    targetFramesList.Add(i);
                                }
                            }
                            else
                            {
                                for (var i = from; i >= to; i--)
                                {
                                    targetFramesList.Add(i);
                                }
                            }
                        }
                        else
                        {
                            targetFramesList.Add(int.Parse(sourceParts[1]));
                        }

                        foreach (var frameId in targetFramesList)
                        {
                            var sourceFrame = sourceFrames[frameId] as AniLoader.AniSpriteFrame;

                            if (flipX)
                            {
                                var newData = new byte[sourceFrame.Data.Length];

                                for (var y = 0; y < sourceFrame.Size.Height; y++)
                                {
                                    for (var x = 0; x < sourceFrame.Size.Width; x++)
                                    {
                                        newData[y * sourceFrame.Size.Width + sourceFrame.Size.Width - x - 1] = sourceFrame.Data[y * sourceFrame.Size.Width + x];
                                    }
                                }

                                sourceFrame.Data         = newData;
                                sourceFrame.OffsetOrigin = new int2((sourceFrame.Size.Width - sourceFrame.OffsetOrigin.X * 2 - 1) / 2, sourceFrame.OffsetOrigin.Y);
                            }

                            if (flipY)
                            {
                                var newData = new byte[sourceFrame.Data.Length];

                                for (var y = 0; y < sourceFrame.Size.Height; y++)
                                {
                                    for (var x = 0; x < sourceFrame.Size.Width; x++)
                                    {
                                        newData[(sourceFrame.Size.Height - y - 1) * sourceFrame.Size.Width + x] = sourceFrame.Data[y * sourceFrame.Size.Width + x];
                                    }
                                }

                                sourceFrame.Data         = newData;
                                sourceFrame.OffsetOrigin = new int2(sourceFrame.OffsetOrigin.X, sourceFrame.Size.Height - sourceFrame.OffsetOrigin.Y - 1);
                            }

                            targetFrames.Add(sourceFrame);
                        }
                    }

                    var currentFrameOffset = 0;
                    var virtualStream      = new MemoryStream();
                    virtualStream.Write(BitConverter.GetBytes((ushort)targetFrames.Count), 0, 2);
                    virtualStream.Write(targetFrames.Count * 18);
                    virtualStream.Write(0);
                    virtualStream.Write(BitConverter.GetBytes((ushort)0xfefe), 0, 2);

                    foreach (var targetFrame in targetFrames)
                    {
                        virtualStream.Write(targetFrame.OffsetOrigin.X);
                        virtualStream.Write(targetFrame.OffsetOrigin.Y);
                        virtualStream.Write(BitConverter.GetBytes((ushort)targetFrame.Size.Width / 2), 0, 2);
                        virtualStream.Write(BitConverter.GetBytes((ushort)targetFrame.Size.Height), 0, 2);
                        virtualStream.Write(BitConverter.GetBytes((ushort)0), 0, 2); // priority
                        virtualStream.Write(currentFrameOffset);
                        currentFrameOffset += targetFrame.Data.Length / 2;
                    }

                    foreach (var targetFrame in targetFrames)
                    {
                        for (var y = 0; y < targetFrame.Size.Height; y++)
                        {
                            for (var x = 0; x < targetFrame.Size.Width; x += 2)
                            {
                                virtualStream.WriteByte(targetFrame.Data[y * targetFrame.Size.Width + x]);
                            }
                        }
                    }

                    virtualAnis.Add(targetAni + ".ani", virtualStream.ToArray());
                }

                contents.AddRange(virtualAnis.Keys);
            }