private void GenerateAndAssertSnapshot(
            Type patternType,
            string patternInterfaceFile,
            string patternImplementationFile,
            string declarationInterfaceFile,
            string targetNameSpace,
            string snapshotName)
        {
            var resolver = this.LoadWorkSpace(
                patternInterfaceFile,
                patternImplementationFile,
                declarationInterfaceFile,
                out var itfDeclaration,
                out var itfPatternDeclaration,
                out var implPatternDeclaration,
                out var files);

            var locator = new RelativeLocator(string.Empty, targetNameSpace);

            var snapshotGenerator = new SnapshotGenerator();

            var implGenerator = new AutomatedGenerator(
                snapshotGenerator, locator, resolver, patternType);

            implGenerator.Generate(files);

            string location = SnapshotHelper.GetLocationFromCallingProjectRoot("Generator");

            SnapshotHelper.AssertSnapshot(snapshotGenerator.GetAllGenerated(), snapshotName, location);
        }
        public void It_should_revert_the_shadow_to_the_original_project_with_package_ref()
        {
            var projectPath = "./Shadow/Lib2.csproj";
            var rootPath    = "./Resources";

            var packages = new Dictionary <string, PackageDeclaration>();

            var packageProjectPath = "./Lib1/Lib1.csproj";
            var packageId          = "PackageLib1";
            var packageProject     = new Project(packageProjectPath);

            packages.Add(packageId, new PackageDeclaration(packageProjectPath, packageId, "3.2.1", new Project[] { packageProject }));

            var project    = new Project(projectPath);
            var aggregator = ShadowProjectHelper.CreateAggregator(rootPath, project, packages);

            var revertShadowService = new ShadowProjectPushService();

            var revertedPath = revertShadowService.PushShadow(aggregator, project);

            var fullPath = Path.Combine(rootPath, revertedPath);

            var snapshotLocation = SnapshotHelper.GetLocationFromCallingCodeProjectRoot("Services");

            SnapshotHelper.AssertSnapshot(
                File.ReadAllText(fullPath),
                nameof(this.It_should_revert_the_shadow_to_the_original_project_with_package_ref),
                snapshotLocation);
        }
        private void GenerateSnapshot(string snapshotName, params string[] files)
        {
            var sc = new ServiceCollection();

            sc.AddTestLogging(this.testOutputHelper);
            sc.AddCSharpToolsGenerator();

            using (var sp = sc.BuildServiceProvider())
            {
                var workspace = sp.GetService <ICSharpWorkspace>();

                foreach (var file in files)
                {
                    workspace.RegisterFile(file);
                }

                var generator = new ToolsGenerator(
                    sp.GetService <ILogger <ToolsGenerator> >(),
                    workspace);

                var inputs  = new HashSet <string>();
                var locator = new RelativeLocator(string.Empty, "target.name.space");

                var snapshotGenerator = new SnapshotGenerator();

                generator.Generate(locator, snapshotGenerator, workspace.Files);

                var location = SnapshotHelper.GetLocationFromCallingProjectRoot(null);
                SnapshotHelper.AssertSnapshot(snapshotGenerator.GetAllGenerated(), snapshotName, location);
            }
        }
        private void GenerateAndAssertSnapshot(
            string patternInterfaceFile,
            string patternImplementationFile,
            string declarationInterfaceFile,
            string targetNameSpace,
            string implName,
            string snapshotName)
        {
            this.LoadWorkSpace(
                patternInterfaceFile,
                patternImplementationFile,
                declarationInterfaceFile,
                out var itfDeclaration,
                out var itfPatternDeclaration,
                out var implPatternDeclaration);

            var locator = new RelativeLocator(string.Empty, targetNameSpace);

            var snapshotGenerator = new SnapshotGenerator();

            var implGenerator = new ImplementationGenerator(
                snapshotGenerator, locator, itfPatternDeclaration, implPatternDeclaration);

            var writerSelector = SetupWriterSelector(itfPatternDeclaration, implPatternDeclaration, itfDeclaration, implName);

            implGenerator.Generate(writerSelector, itfDeclaration, implName);

            string location = SnapshotHelper.GetLocationFromCallingProjectRoot("Generator");

            SnapshotHelper.AssertSnapshot(snapshotGenerator.GetAllGenerated(), snapshotName, location);
        }
        private void GenerateShadowAndAssertSnapshot(string rootPath, string projectPath, Dictionary <string, PackageDeclaration> packages, string snapshotName)
        {
            var shadowFullPath = ShadowProjectHelper.GenerateShadow(rootPath, projectPath, packages);

            var snapshotLocation = SnapshotHelper.GetLocationFromCallingCodeProjectRoot("Services");

            SnapshotHelper.AssertSnapshot(
                File.ReadAllText(shadowFullPath),
                snapshotName,
                snapshotLocation);
        }
示例#6
0
 public UserController(IOptions <NanokaOptions> options, IUserRepository users, ILocker locker, IMapper mapper,
                       IUserClaims claims, PasswordHashHelper hash, SnapshotHelper snapshot, TokenManager tokens)
 {
     _options  = options.Value;
     _users    = users;
     _locker   = locker;
     _mapper   = mapper;
     _claims   = claims;
     _hash     = hash;
     _snapshot = snapshot;
     _tokens   = tokens;
 }
示例#7
0
 public BookController(IBookRepository books, ILocker locker, IStorage storage, IMapper mapper,
                       UploadManager uploads, SnapshotHelper snapshots, ImageProcessor image, VoteHelper votes)
 {
     _books     = books;
     _locker    = locker;
     _storage   = storage;
     _mapper    = mapper;
     _uploads   = uploads;
     _snapshots = snapshots;
     _image     = image;
     _votes     = votes;
 }
示例#8
0
        public void SnapshotHelper_CaptureTempSnapshot()
        {
            AutomationElement element = TestUtility.GetCalculatorButton1Element();
            string            token   = null;

            SnapshotHelper.CaptureTempSnapshot(element, out token);

            Assert.IsNotNull(token);

            TestUtility.ExitWindowCalculator();

            try
            {
                SnapshotHelper.CaptureTempSnapshot(element, out token);
                Assert.Fail("element not available, should throw ElementNotAvailableException");
            }
            catch (ElementNotAvailableException)
            {
                Assert.IsTrue(true); //succeed
            }
        }
        public void AddObjectsWindow_CaptureTempSnapshot()
        {
            ObjectDescriptor  descriptor = ObjectDescriptor.FromJson(@"
            {
                ""ntype"": ""uia"",
                ""nname"": ""Window: Calculator"",
                ""identifyProperties"": {
                    ""type"": ""Window"",
                    ""className"": ""QWidget"",
                    ""title"": ""Calculator""
                }
            }");
            UIATestObject     testObject = (UIATestObject)descriptor.GetObject();
            AutomationElement element    = testObject.AutomationElement;

            string elementInfo = UIAUtility.DumpAutomationElement(element);

            Debug.WriteLine(elementInfo);

            AddObjectsWindow window = new AddObjectsWindow(null);

            string token;

            SnapshotHelper.CaptureTempSnapshot(element, out token);

            CacheHandler handler = new CacheHandler(AppEnvironment.CurrentDirectory);

            string targetPath = Path.Combine(Environment.CurrentDirectory, "calculator.png");

            handler.MoveCachedItemToFile(token, targetPath);
            Assert.IsTrue(File.Exists(targetPath));

            Image image = Image.FromFile(targetPath);

            Assert.AreEqual(302 + 20, image.Size.Width);
            Assert.AreEqual(317 + 20, image.Size.Height);
        }
示例#10
0
        public override object[] Connect(params object[] Parameters)
        {
            object[] returnValue = null;

            string operationName = Parameters[0] != null ? Parameters[0].ToString() : null;

            Operation operation = !String.IsNullOrEmpty(operationName) ? this.GetOperation(operationName) : this.GetOperation(0);

            string message = Parameters[1] != null ? Parameters[1].ToString() : operation.Message;

            RDBMSHelper helper = new RDBMSHelper();

            //if (this.snapshotCache == null)
            //{
            //    string snapshotLoaction = operation.GetArgumentValue("SnapshotLocation");

            //    //Snapshot loading and initialization to be implemented below:
            //    //
            //}

            helper.EnableTracing   = ((!String.IsNullOrEmpty(operation.GetArgumentValue("EnableTracing"))) && (operation.GetArgumentValue("EnableTracing").ToLower() == "true"));
            helper.TraceSourceName = operation.GetArgumentValue("TraceSourceName");

            if (operation.Method == OperationMethod.BatchWrite)
            {
                string bulkCopyAssemblyName = operation.GetArgumentValue("BulkCopyAssemblyName");
                string bulkCopyTypeName     = operation.GetArgumentValue("BulkCopyTypeName");

                return(new object[] { helper.BulkCopy(message, this.Protocol.Component, this.Address, operation.Message, bulkCopyAssemblyName, bulkCopyTypeName) });
            }
            else if (operation.Method == OperationMethod.Retrieve)
            {
                string encodingName = operation.GetArgumentValue("DataSetXmlEncoding");

                return(new object[] { helper.GetData(this.Protocol.Component, this.Address, this.DataType, operation.Message, operation.GetArgumentValue("CommandType"), encodingName) });
            }
            else if (operation.Method == OperationMethod.Modify)
            {
                SnapshotHelper snapshotHelper = new SnapshotHelper();

                if (this.snapshotCache == null)
                {
                    //Snapshot population from persistency mechanism to be implemented below:
                    //

                    this.snapshotCache = snapshotHelper.GetMostRecentSnapshot(operation.GetArgumentValue("SnapshotLocation"), operation.GetArgumentValue("DataSetXmlEncoding"));
                }

                string snapshot = this.snapshotCache != null?this.snapshotCache.ToString() : null;

                //this.snapshotCache = message;

                //if (String.IsNullOrEmpty(snapshot))
                //{
                //    snapshot = message;
                //}

                //Snapshot persistency to be implemented below:
                //

                //if (this.snapshotCache == null)
                //{
                //    returnValue = new object[] { helper.BulkCopy(message, this.Protocol.Component, this.Address, operation.GetArgumentValue("DestinationTableName"), operation.GetArgumentValue("BulkCopyAssemblyName"), operation.GetArgumentValue("BulkCopyTypeName"), true) };
                //}
                //else
                {
                    IDictionary <string, IDictionary <string, string> > primaryKeyDictionary = (this.PrimaryKeys != null) ? this.PrimaryKeys.GetRefDataTypes() : null;

                    IDictionary <string, IDictionary <string, string> > foreignKeyDictionary = (this.ForeignKeys != null) ? this.ForeignKeys.GetRefDataTypes() : null;

                    Dictionary <string, string[]> primaryKeys = new Dictionary <string, string[]>();

                    foreach (string dataTableName in primaryKeyDictionary.Keys)
                    {
                        if (!primaryKeys.ContainsKey(dataTableName))
                        {
                            primaryKeys.Add(dataTableName, primaryKeyDictionary[dataTableName].Values.ToArray());
                        }
                        else
                        {
                            primaryKeys[dataTableName] = primaryKeyDictionary[dataTableName].Values.ToArray();
                        }
                    }

                    returnValue = new object[] { helper.Update(this.Protocol.Component, this.Address, this.DataType, operation.Message, operation.GetArgumentValue("CommandType"), OperationMethod.Modify, snapshot, message, operation.GetArgumentValue("DataSetXmlEncoding"), primaryKeys, foreignKeyDictionary) };
                }

                this.snapshotCache = message;

                snapshotHelper.SetSnapshot(operation.GetArgumentValue("SnapshotLocation"), message, operation.GetArgumentValue("DataSetXmlEncoding"));

                return(returnValue);
            }
            else
            {
                return(new object[] { helper.Query(this.Protocol.Component, this.Address, operation.Message, operation.GetArgumentValue("CommandType"), operation.Method) });
            }
        }
示例#11
0
        //Test Process Close()
        //cn_process.Close();//
        //End Test

        //Diagnostic Window Test
        //SnapshotHelper.Print_Process_Window_Dimensions(cn_process);
        //End Test

        //Test Launcher Copy and Compare
        //Bitmap screen = SnapshotHelper.Take_Snapshot_Process(cn_process, 491, 436, 183, 41);
        //Bitmap refScreen = new Bitmap("reference.PNG");
        //Bitmap queue_img = new Bitmap("join.bmp");
        //Image_Manipulator.Compare_Image_Section(refScreen, queue_img, new Rectangle(491, 436, 183, 41), new Rectangle(0, 0, queue_img.Width, queue_img.Height));
        //End Test

        //Loop for test comparison of live results
        //TODO: Add listener for Lol.exe to know when it closes and resume scanning. Assuming user will want to queue for another game
        //TODO: Add listener to LolClient.exe to when the user closes it, shutdown the app. Currently working prototype
        //TODO: Add implementation for normal blind pick
        //TODO: Bug starting program before league starts endless Error Loop - workaround repress button
        //Connect to phone
        //TODO: On activation of queue pop, move process window to active, so that click corresponds to the proper progam
        // Server_Socket.StartListening();
        //end connect

        // COMMENTED OUT PROGRAM CODE FOR OTHER TESTS
        public static void Analyze_Process(Process_Object cn_process)
        {
            //Console.Write(Program_Importer.programs.ElementAt(choice).ToString());
            bool            queue_popped       = false; //CHANGE TO FALSE OR BROKEN
            bool            is_active          = true;
            bool            main_game_launched = false; //Need to actually start a game to get name of the process
            int             counter            = 0;
            Program_Profile chosen             = Program_Importer.programs.ElementAt(choice);
            Bitmap          screen             = null;

            // Bitmap queue_img = new Bitmap("join.bmp"); // Can Cache image in order to increase perfomance, image is also hardcoded
            byte[,,] pixelValues = Image_Manipulator.Store_Image_Value(chosen.Get_Image(), Image_Manipulator.DEFAULT_RESIZE);
            while (!queue_popped && is_active)
            {
                is_active = cn_process.IsOpen();
                if (is_active == false)
                {
                    Console.Clear();
                    Console.Write("Process has closed. Closing Program...");
                    return;
                }


                try
                {
                    screen = SnapshotHelper.Take_Snapshot_Process(cn_process, chosen);
                    // if (Image_Manipulator.Compare_Image(Program_Importer.programs.ElementAt(choice).Get_Image(), screen) && Program_Importer.programs.ElementAt(choice).Get_MatchMode()) queue_popped = true;
                    if (Image_Manipulator.Compare_Image(pixelValues, screen, Image_Manipulator.DEFAULT_RESIZE) && chosen.Get_MatchMode())
                    {
                        queue_popped = true;
                    }
                    else
                    {
                        queue_popped = false;
                    }
                }
                catch (Exception e)
                {
                    Console.Write("\nError: " + e.ToString());
                }
                //Console.Write(queue_popped);
                System.Threading.Thread.Sleep(250);
                if (counter == 100)
                {
                    GC.Collect();
                    counter = 0;
                }
                counter++;
            }

            if (chosen.Get_AutoStatus())
            {
                Process_Object.Click(cn_process, chosen);
            }
            //if (queue_popped == true) Server_Socket.SendSignal("Popped");
            //else Server_Socket.SendSignal("Closed");
            //End Test


            //Socket Tests
            //Server_Socket.StartListening();
            //End Socket Tests

            //Close connection
            //Server_Socket.GoDeaf();
            //End Close

            Console.Write("\nClick to Restart");
            //Console.Clear();
        }