private ExampleData LoadExampleData(int index)
    {
        currentSheet = "ExampleSheet";
        currentRows = dataReader.GetRows(currentSheet);

        int edId = 0;
        TryLoadInt (0, "Id", out edId);

        ExampleData exampleDataObject = new ExampleData(edId);

        TryLoadString (0, "Name", out exampleDataObject.name);

        exampleDataObject.levelDatas = new List<ExampleData.LevelData>();

        // Level 0 skip
        exampleDataObject.levelDatas.Add (new ExampleData.LevelData());

        int rowNum = currentRows.Count;
        for (int i = 0; i < rowNum; i++)
        {
            ExampleData.LevelData levelDataObject = new ExampleData.LevelData();

            TryLoadBigInteger(i, "Coin", out levelDataObject.coin);
            TryLoadBigInteger(i, "UpgradeCost", out levelDataObject.upgradeCost);

            exampleDataObject.levelDatas.Add(levelDataObject);
        }

        return exampleDataObject;
    }
Beispiel #2
0
        public static void Main(string[] args)
        {
            var data = new ExampleData();
            var child = new Person()
            {
                Name = "Child " + (char)(new Random().Next(40, 100) - '1'),
            };
            data.People.Add(child);
            data.People.SaveChanges();
            var newPerson = new Person()
            {
                Name = "Parent " + (char)(new Random().Next(40, 100) - '1'),
            };

            data.People.Add(newPerson);
            data.People.SaveChanges();

            //data.Kids.Add(new Kid() { ChildId = child.Id, ParentId = newPerson.Id });
            //data.Kids.SaveChanges();

            var people = data.People.All().ToList();

            foreach (var person in people)
            {
                var fatherName = person.Father == null ? string.Empty : person.Father.Name;
                var motherName = person.Mother == null ? string.Empty : person.Mother.Name;
                Console.WriteLine("Name: {0} Id: {1}", person.Name, person.Id);
                Console.WriteLine("Father: {0} Mother: {1}", fatherName, motherName);
                var children = data.Kids.All().ToList();
                //Console.WriteLine(children);
                foreach (var kid in children)
                {
                    Console.WriteLine("Kid: {0}", kid.Child.Name);
                    Console.WriteLine("Parent: {0}", kid.Parent.Name);
                }

                data.People.Delete(person);
            }

            data.People.SaveChanges();

            //var newStore = new Store()
            //{
            //    OwnerId = newPerson.Id,
            //};
            //data.Stores.Add(newStore);
            //data.Stores.SaveChanges();
            //var stores = data.Stores.All().ToList();
            //foreach (var store in stores)
            //{
            //    Console.WriteLine("StoreId: {0} Owner: {1}", store.Id, store.Owner.Name);
            //}
        }
        public static ExampleData GetCrossJoinViewModel()
        {
            var data = new ExampleData
            {
                Explanation    = Properties.Resources.CrossJoinExplanation,
                GridSource     = DataAccess.GetCrossJoinData(),
                TableOneSource = DataAccess.GetTableOneSource(),
                TableTwoSource = DataAccess.GetTableTwoSource(),
                QueryUsed      = Properties.Resources.CrossJoinQuery,
                Title          = "Cross Join"
            };

            return(data);
        }
Beispiel #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int added = 0;

            for (int i = 0; i < 100; i++)
            {
                using (ExampleData data = new ExampleData())
                    if (AppLogic.CreatePatient(data.ExamplePatient()))
                    {
                        added++;
                    }
            }
            MessageBox.Show($"Dodadno {added} pacjentów.");
        }
Beispiel #5
0
        public void CreateInvalidPatientTest()
        {
            TestDBConnector fakeDBModel = new TestDBConnector();
            Logic           testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                Patient p = data.ExamplePatient();
                p.Name = "ja";
                bool ret = testLogic.CreatePatient(p);

                Assert.AreEqual(false, ret);
            }
        }
        public static ExampleData GetRightJoinViewModel()
        {
            var data = new ExampleData
            {
                Explanation    = Properties.Resources.RightJoinExplanation,
                GridSource     = DataAccess.GetRightJoinData(),
                TableOneSource = DataAccess.GetTableOneSource(),
                TableTwoSource = DataAccess.GetTableTwoSource(),
                QueryUsed      = App.Config.DatabaseType == GlobalStrings.DataBaseTypes.SqlLite
                    ? Properties.Resources.RightJoinQuerySqlite : Properties.Resources.RightJoinQuery,
                Title = "Right Join"
            };

            return(data);
        }
Beispiel #7
0
        public void DeletePatientTest()
        {
            TestDBConnector fakeDBModel = new TestDBConnector();
            Logic           testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                Patient p = data.ExamplePatient();
                testLogic.CreatePatient(p);

                bool ret = testLogic.DeletePatient(p);

                Assert.AreEqual(0, fakeDBModel.__patients.Count);
            }
        }
Beispiel #8
0
        private static IEnumerable <object[]> GetExampleData()
        {
            foreach (var streamName in typeof(ExamplesTests).Assembly.GetManifestResourceNames().Where(p => p.StartsWith("docs/examples/")))
            {
                var extension = Path.GetExtension(streamName);
                if (!StringComparer.OrdinalIgnoreCase.Equals(extension, ".bicep"))
                {
                    continue;
                }

                var exampleData = new ExampleData(streamName, Path.ChangeExtension(streamName, "json"));

                yield return(new object[] { exampleData });
            }
        }
Beispiel #9
0
        public void UpdatePatientTest()
        {
            TestDBConnector fakeDBModel = new TestDBConnector();
            Logic           testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                Patient p = data.ExamplePatient();
                testLogic.CreatePatient(p);
                p.Name = "Ania";
                bool ret = testLogic.UpdatePatient(p);
                Assert.AreEqual(true, ret);
                Assert.AreEqual("Ania", fakeDBModel.__patients[0].Name);
            }
        }
Beispiel #10
0
        public void ShowVisitsTestAnyVisit()
        {
            TestDBConnector fakeDBModel = new TestDBConnector();
            Logic           testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                Doctor dr = data.ExampleDoctor();
                testLogic.AddDoctor(dr);
                DateTime dt = data.ExampleTime();

                IEnumerable <Visit> list = testLogic.ShowVisits(dt.Date, dt.Hour.ToString(), 24.ToString(), dr.Surname, "", dr.Specialization, true, 0, 1);

                Assert.AreNotEqual(null, list.First().Date);
            }
        }
Beispiel #11
0
        public async Task <PartialViewResult> LoadCalendarPartial(DateTime date)
        {
            if (!User.Identity.IsAuthenticated)
            {
                var exampleMonthSummaryActivity = ExampleData.GetMonthSummaryActivities();
                return(PartialView("_CalendarPartial", exampleMonthSummaryActivity));
            }

            httpContextHelper.Context = HttpContext;
            string accessToken = httpContextHelper.getAccessToken();
            int    stravaId    = Convert.ToInt32(User.FindFirst("stravaId").Value);

            var monthSummaryActivities = (await summaryService.GetMonthSummaryActivities(accessToken, stravaId, date)).ToList();

            return(PartialView("_CalendarPartial", monthSummaryActivities));
        }
        public async Task <PartialViewResult> LoadMapPartial()
        {
            if (!User.Identity.IsAuthenticated)
            {
                var exampleActivityCoordinates = ExampleData.ActivityCoordinatesList();
                return(PartialView("_BingMapPartial", exampleActivityCoordinates));
            }

            _httpContextHelper.Context = HttpContext;
            string accessToken = _httpContextHelper.getAccessToken();
            int    stravaId    = Convert.ToInt32(User.FindFirst("stravaId").Value);

            var activityCoordinates = (await mapCoordinatesService.GetActivityCoordinates(accessToken, stravaId)).ToList();

            return(PartialView("_BingMapPartial", activityCoordinates));
        }
Beispiel #13
0
        public static void Main(string[] args)
        {
            string      dataFilePath = "./Data/ExampleData.json";
            ExampleData data         = Program.GetData(dataFilePath);

            string   liquidTemplateFilePath = "./Templates/ExampleTemplate.liquid";
            Template template = Program.GetTemplate(liquidTemplateFilePath);

            Hash hash = Hash.FromAnonymousObject(new { Model = data });

            string renderedOutput = template.Render(hash);

            Console.WriteLine(renderedOutput);

            File.WriteAllText($"{Directory.GetCurrentDirectory()}/Output/RenderedTemplate.html", renderedOutput);
        }
Beispiel #14
0
        public static FileTreeNode InitFileTree()
        {
            //进行通信,拉取用户的数据。
            ClientAdapt.Open();
            TVssService.Client client  = ClientAdapt.GetClient();
            string             strTree = client.GetFileTree(GetValidator());

            ClientAdapt.Close();
            if (strTree == "None")
            {
                return(ExampleData.getInitUserFileTree());
            }
            else
            {
                return(JsonConvert.DeserializeObject <FileTreeNode>(strTree));
            }
        }
        public PartialViewResult LoadMapPartial()
        {
            if (!User.Identity.IsAuthenticated)
            {
                var exampleCoordinates = _map.getCoordinates(ExampleData.MapVisualActivitiesList());
                return(PartialView("_BingMapPartial", exampleCoordinates));
            }

            _httpContextHelper.Context = HttpContext;
            string accessToken = _httpContextHelper.getAccessToken();
            int    stravaId    = Convert.ToInt32(User.FindFirst("stravaId").Value);
            var    user        = getUpdatedUserActivities(accessToken, stravaId);

            var coordinates = _map.getCoordinates(user.VisualActivities);

            return(PartialView("_BingMapPartial", coordinates));
        }
        public PartialViewResult LoadCalendarPartial(DateTime date)
        {
            if (!User.Identity.IsAuthenticated)
            {
                MonthSummary exampleMonthSummary = ExampleData.GetMonthSummary();
                return(PartialView("_CalendarPartial", exampleMonthSummary));
            }

            _httpContextHelper.Context = HttpContext;
            string accessToken = _httpContextHelper.getAccessToken();
            int    stravaId    = Convert.ToInt32(User.FindFirst("stravaId").Value);
            var    user        = getUpdatedUserActivities(accessToken, stravaId);

            MonthSummary monthSummary = new MonthSummary(date, user.VisualActivities.ToList());

            return(PartialView("_CalendarPartial", monthSummary));
        }
Beispiel #17
0
        public void AddVisitTest()
        {
            TestDBConnector fakeDBModel = new TestDBConnector();
            Logic           testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                Patient  p  = data.ExamplePatient();
                Doctor   dr = data.ExampleDoctor();
                DateTime dt = data.ExampleTime();

                testLogic.AddVisit(dt, p, dr);


                Assert.AreEqual(1, fakeDBModel.__visits.Count);
            }
        }
Beispiel #18
0
        public void ExampleIsValid(ExampleData example)
        {
            // save all the files in the containing directory to disk so that we can test module resolution
            var parentStream    = Path.GetDirectoryName(example.BicepStreamName) !.Replace('\\', '/');
            var outputDirectory = FileHelper.SaveEmbeddedResourcesWithPathPrefix(TestContext, typeof(ExamplesTests).Assembly, example.OutputFolderName, parentStream);
            var bicepFileName   = Path.Combine(outputDirectory, Path.GetFileName(example.BicepStreamName));
            var jsonFileName    = Path.Combine(outputDirectory, Path.GetFileName(example.JsonStreamName));

            var syntaxTreeGrouping = SyntaxTreeGroupingBuilder.Build(new FileResolver(), new Workspace(), PathHelper.FilePathToFileUrl(bicepFileName));
            var compilation        = new Compilation(new AzResourceTypeProvider(), syntaxTreeGrouping);
            var emitter            = new TemplateEmitter(compilation.GetEntrypointSemanticModel());

            // group assertion failures using AssertionScope, rather than reporting the first failure
            using (new AssertionScope())
            {
                foreach (var(syntaxTree, diagnostics) in compilation.GetAllDiagnosticsBySyntaxTree())
                {
                    var nonPermittedDiagnostics = diagnostics.Where(x => !IsPermittedMissingTypeDiagnostic(x));

                    nonPermittedDiagnostics.Should().BeEmpty($"\"{syntaxTree.FileUri.LocalPath}\" should not have warnings or errors");
                }

                var exampleExists = File.Exists(jsonFileName);
                exampleExists.Should().BeTrue($"Generated example \"{jsonFileName}\" should be checked in");

                using var stream = new MemoryStream();
                var result = emitter.Emit(stream);

                result.Status.Should().Be(EmitStatus.Succeeded);

                if (result.Status == EmitStatus.Succeeded)
                {
                    stream.Position = 0;
                    var generated = new StreamReader(stream).ReadToEnd();

                    var actual = JToken.Parse(generated);
                    File.WriteAllText(jsonFileName + ".actual", generated);

                    actual.Should().EqualWithJsonDiffOutput(
                        TestContext,
                        exampleExists ? JToken.Parse(File.ReadAllText(jsonFileName)) : new JObject(),
                        example.JsonStreamName,
                        jsonFileName + ".actual");
                }
            }
        }
Beispiel #19
0
        public void SearchPatientBySurnameNameAndCityTest()
        {
            IDBModels fakeDBModel = new TestDBConnector();
            Logic     testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                Patient p1 = data.ExamplePatient();
                Patient p2 = data.ExamplePatient();
                testLogic.CreatePatient(p1);
                testLogic.CreatePatient(p2);

                List <Patient> list = (List <Patient>)testLogic.SearchPatient("", p1.Surname, p1.Name, p1.Address.City, 0, 1);

                Assert.AreEqual(p1.PESELNumber, list[0].PESELNumber);
            }
        }
Beispiel #20
0
        public void SearchDoctorBySpecAndSurnameTest()
        {
            IDBModels fakeDBModel = new TestDBConnector();
            Logic     testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                Doctor dr1 = data.ExampleDoctor();
                Doctor dr2 = data.ExampleDoctor();
                testLogic.AddDoctor(dr1);
                testLogic.AddDoctor(dr2);

                List <Doctor> list = (List <Doctor>)testLogic.SearchDoctor(dr1.Specialization, dr1.Surname, "", "", 0, 1);

                Assert.AreEqual(dr1.LicenseNumber, list[0].LicenseNumber);
            }
        }
Beispiel #21
0
        public void InvalidArgumentsSearchPatientTest()
        {
            IDBModels fakeDBModel = new TestDBConnector();
            Logic     testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                Patient p1 = data.ExamplePatient();
                Patient p2 = data.ExamplePatient();
                testLogic.CreatePatient(p1);
                testLogic.CreatePatient(p2);

                List <Patient> list = (List <Patient>)testLogic.SearchPatient("", "", "", "", 0, 1);

                Assert.AreEqual(null, list);
            }
        }
Beispiel #22
0
        public void ShowVisitsTestNull()
        {
            TestDBConnector fakeDBModel = new TestDBConnector();
            Logic           testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                ;
                Doctor   dr = data.ExampleDoctor();
                DateTime dt = data.ExampleTime();

                var list = testLogic.ShowVisits(dt, 8.ToString(), 20.ToString(), dr.Name, "", dr.Specialization, true, 0, 0);


                Assert.AreEqual(null, list);
            }
        }
        public static string ContrastColor(this ExampleData model)
        {
            var red   = int.Parse(model.Color.Substring(1, 2), System.Globalization.NumberStyles.HexNumber);
            var Green = int.Parse(model.Color.Substring(3, 2), System.Globalization.NumberStyles.HexNumber);
            var blue  = int.Parse(model.Color.Substring(5, 2), System.Globalization.NumberStyles.HexNumber);

            //https://en.wikipedia.org/wiki/Rec._709
            var luma = (0.2126 * red) + (0.7152 * Green) + (0.0722 * blue);

            if (luma >= 165)
            {
                return("#000000");
            }
            else
            {
                return("#ffffff");
            }
        }
        internal virtual void EnsureSeedData()
        {
            var exampleData = new ExampleData();

            if (!this.configurationDbContext.IdentityResources.Any())
            {
                foreach (var resource in exampleData.GetIdentityResources())
                {
                    this.configurationDbContext.IdentityResources
                    .Add(resource.ToEntity());
                }
                this.configurationDbContext.SaveChanges();
            }

            if (!this.configurationDbContext.ApiResources.Any())
            {
                foreach (var resource in exampleData.GetApiResources())
                {
                    this.configurationDbContext.ApiResources
                    .Add(resource.ToEntity());
                }
                this.configurationDbContext.SaveChanges();
            }

            if (!this.configurationDbContext.Clients.Any())
            {
                foreach (var client in exampleData.GetClients())
                {
                    this.configurationDbContext.Clients.Add(client.ToEntity());
                }
                this.configurationDbContext.SaveChanges();
            }

            if (!this.userAccountDbContext.UserAccounts.Any())
            {
                foreach (var userAccount in exampleData
                         .GetUserAccounts(this.crypto, this.appOptions))
                {
                    this.userAccountDbContext.UserAccounts
                    .Add(userAccount.ToEntity());
                }
                this.userAccountDbContext.SaveChanges();
            }
        }
        // obtains the data and calculates the grid of results
        private static void calculate(CalculationRunner runner)
        {
            // the trades that will have measures calculated
            IList <Trade> trades = createSwapTrades();

            // the columns, specifying the measures to be calculated
            IList <Column> columns = ImmutableList.of(Column.of(Measures.LEG_INITIAL_NOTIONAL), Column.of(Measures.PRESENT_VALUE), Column.of(Measures.LEG_PRESENT_VALUE), Column.of(Measures.PV01_CALIBRATED_SUM), Column.of(Measures.PAR_RATE), Column.of(Measures.ACCRUED_INTEREST), Column.of(Measures.PV01_CALIBRATED_BUCKETED), Column.of(AdvancedMeasures.PV01_SEMI_PARALLEL_GAMMA_BUCKETED));

            // load quotes
            ImmutableMap <QuoteId, double> quotes = QuotesCsvLoader.load(VAL_DATE, QUOTES_RESOURCE);

            // load fixings
            ImmutableMap <ObservableId, LocalDateDoubleTimeSeries> fixings = FixingSeriesCsvLoader.load(FIXINGS_RESOURCE);

            // create the market data
            MarketData marketData = MarketData.of(VAL_DATE, quotes, fixings);

            // the reference data, such as holidays and securities
            ReferenceData refData = ReferenceData.standard();

            // load the curve definition
            IDictionary <CurveGroupName, RatesCurveGroupDefinition> defns = RatesCalibrationCsvLoader.load(GROUPS_RESOURCE, SETTINGS_RESOURCE, CALIBRATION_RESOURCE);
            RatesCurveGroupDefinition curveGroupDefinition = defns[CURVE_GROUP_NAME].filtered(VAL_DATE, refData);

            // the configuration that defines how to create the curves when a curve group is requested
            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(CURVE_GROUP_NAME, curveGroupDefinition).build();

            // the complete set of rules for calculating measures
            CalculationFunctions  functions   = StandardComponents.calculationFunctions();
            RatesMarketDataLookup ratesLookup = RatesMarketDataLookup.of(curveGroupDefinition);
            CalculationRules      rules       = CalculationRules.of(functions, ratesLookup);

            // calibrate the curves and calculate the results
            MarketDataRequirements reqs = MarketDataRequirements.of(rules, trades, columns, refData);
            MarketData             calibratedMarketData = marketDataFactory().create(reqs, marketDataConfig, marketData, refData);
            Results results = runner.calculate(rules, trades, columns, calibratedMarketData, refData);

            // use the report runner to transform the engine results into a trade report
            ReportCalculationResults calculationResults = ReportCalculationResults.of(VAL_DATE, trades, columns, results, functions, refData);
            TradeReportTemplate      reportTemplate     = ExampleData.loadTradeReportTemplate("swap-report-template");
            TradeReport tradeReport = TradeReport.of(calculationResults, reportTemplate);

            tradeReport.writeAsciiTable(System.out);
        }
Beispiel #26
0
    public static ExampleData LoadExample()
    {
        string path = Application.persistentDataPath + "/" + CurrentSave.ToString("D2") + "_save.example";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            ExampleData data = (ExampleData)formatter.Deserialize(stream);
            stream.Close();

            return(data);
        }
        else
        {
            Debug.Log("Save file not found in " + path + ", Creating new save...");
            return(null);
        }
    }
Beispiel #27
0
        public void Decompiler_generates_expected_bicep_files_with_diagnostics(ExampleData example)
        {
            // save all the files in the containing directory to disk so that we can test module resolution
            var parentStream    = Path.GetDirectoryName(example.BicepStreamName) !.Replace('\\', '/');
            var outputDirectory = FileHelper.SaveEmbeddedResourcesWithPathPrefix(TestContext, typeof(DecompilationTests).Assembly, parentStream);
            var bicepFileName   = Path.Combine(outputDirectory, Path.GetFileName(example.BicepStreamName));
            var jsonFileName    = Path.Combine(outputDirectory, Path.GetFileName(example.JsonStreamName));
            var typeProvider    = AzResourceTypeProvider.CreateWithAzTypes();

            var(bicepUri, filesToSave) = TemplateDecompiler.DecompileFileWithModules(typeProvider, new FileResolver(), PathHelper.FilePathToFileUrl(jsonFileName));

            var syntaxTrees = filesToSave.Select(kvp => SyntaxTree.Create(kvp.Key, kvp.Value));
            var workspace   = new Workspace();

            workspace.UpsertSyntaxTrees(syntaxTrees);

            var syntaxTreeGrouping      = SyntaxTreeGroupingBuilder.Build(new FileResolver(), workspace, bicepUri);
            var compilation             = new Compilation(typeProvider, syntaxTreeGrouping);
            var diagnosticsBySyntaxTree = compilation.GetAllDiagnosticsBySyntaxTree();

            using (new AssertionScope())
            {
                foreach (var syntaxTree in syntaxTreeGrouping.SyntaxTrees)
                {
                    var exampleExists = File.Exists(syntaxTree.FileUri.LocalPath);
                    exampleExists.Should().BeTrue($"Generated example \"{syntaxTree.FileUri.LocalPath}\" should be checked in");

                    var diagnostics = diagnosticsBySyntaxTree[syntaxTree];
                    var bicepOutput = filesToSave[syntaxTree.FileUri];

                    var sourceTextWithDiags = OutputHelper.AddDiagsToSourceText(bicepOutput, Environment.NewLine, diagnostics, diag => OutputHelper.GetDiagLoggingString(bicepOutput, outputDirectory, diag));
                    File.WriteAllText(syntaxTree.FileUri.LocalPath + ".actual", sourceTextWithDiags);

                    sourceTextWithDiags.Should().EqualWithLineByLineDiffOutput(
                        TestContext,
                        exampleExists ? File.ReadAllText(syntaxTree.FileUri.LocalPath) : "",
                        expectedLocation: Path.Combine("src", "Bicep.Decompiler.IntegrationTests", parentStream, Path.GetRelativePath(outputDirectory, syntaxTree.FileUri.LocalPath)),
                        actualLocation: syntaxTree.FileUri.LocalPath + ".actual");
                }
            }
        }
Beispiel #28
0
        public void ShowPatientVisitsTest()
        {
            TestDBConnector fakeDBModel = new TestDBConnector();
            Logic           testLogic   = new Logic(fakeDBModel);

            using (ExampleData data = new ExampleData(0))
            {
                Patient  p  = data.ExamplePatient();
                Doctor   dr = data.ExampleDoctor();
                DateTime dt = data.ExampleTime();
                testLogic.CreatePatient(p);
                testLogic.AddDoctor(dr);
                testLogic.AddVisit(dt, p, dr);

                List <Visit> list = (List <Visit>)testLogic.ShowPatientVisits(p);

                Assert.AreEqual(p.PESELNumber, list[0].Patient.PESELNumber);
                Assert.AreEqual(dr.LicenseNumber, list[0].Doctor.LicenseNumber);
                Assert.AreEqual(dt, list[0].DT);
            }
        }
Beispiel #29
0
    ExampleData LoadFromInspector2()
    {
        ExampleData data = null;//clear current data

        ShowConsole();

        if (File.Exists(Application.persistentDataPath + Path.DirectorySeparatorChar + "GCExampleData.txt"))
        {
            data = ScriptableObject.CreateInstance <ExampleData>();
            string json = File.ReadAllText(Application.persistentDataPath + Path.DirectorySeparatorChar + "GCExampleData.txt");
            JsonUtility.FromJsonOverwrite(json, data);
            Debug.Log("Save Data Loaded From File");

            //ExampleData = data;
        }
        else
        {
            data = Resources.Load <ExampleData>("Example Data");
            Debug.Log("Save Could Not Be Found");
        }
        return(data);
    }
Beispiel #30
0
        private static IEnumerable <object[]> GetExampleData()
        {
            const string pathPrefix     = "docs/examples/";
            const string bicepExtension = ".bicep";

            foreach (var streamName in typeof(ExamplesTests).Assembly.GetManifestResourceNames().Where(p => p.StartsWith(pathPrefix, StringComparison.Ordinal)))
            {
                var extension = Path.GetExtension(streamName);
                if (!StringComparer.OrdinalIgnoreCase.Equals(extension, bicepExtension))
                {
                    continue;
                }

                var outputFolderName = streamName
                                       .Substring(0, streamName.Length - bicepExtension.Length)
                                       .Substring(pathPrefix.Length)
                                       .Replace('/', '_');

                var exampleData = new ExampleData(streamName, Path.ChangeExtension(streamName, "json"), outputFolderName);

                yield return(new object[] { exampleData });
            }
        }
Beispiel #31
0
        private static IEnumerable <object[]> GetExampleData()
        {
            const string resourcePrefix = "Bicep.Core.Samples.DocsExamples.";
            const string bicepExtension = ".bicep";
            const string jsonExtension  = ".json";

            var bicepResources = Assembly.GetExecutingAssembly().GetManifestResourceNames().Where(name => name.StartsWith(resourcePrefix) && name.EndsWith(bicepExtension));

            bicepResources.Should().NotBeEmpty("examples should be included for tests");

            foreach (var bicepResource in bicepResources)
            {
                var jsonResource = bicepResource.Substring(0, bicepResource.Length - bicepExtension.Length) + jsonExtension;

                var example = new ExampleData(
                    jsonContents: DataSet.ReadFile(jsonResource),
                    bicepContents: DataSet.ReadFile(bicepResource),
                    bicepFileName: bicepResource.Substring(resourcePrefix.Length)
                    );

                yield return(new object[] { example });
            }
        }
Beispiel #32
0
        public void Example_uses_consistent_formatting(ExampleData example)
        {
            // save all the files in the containing directory to disk so that we can test module resolution
            var parentStream    = Path.GetDirectoryName(example.BicepStreamName) !.Replace('\\', '/');
            var outputDirectory = FileHelper.SaveEmbeddedResourcesWithPathPrefix(TestContext, typeof(ExamplesTests).Assembly, example.OutputFolderName, parentStream);

            var bicepFileName    = Path.Combine(outputDirectory, Path.GetFileName(example.BicepStreamName));
            var originalContents = File.ReadAllText(bicepFileName);
            var program          = ParserHelper.Parse(originalContents);

            var printOptions = new PrettyPrintOptions(NewlineOption.LF, IndentKindOption.Space, 2, true);

            var formattedContents = PrettyPrinter.PrintProgram(program, printOptions);

            formattedContents.Should().NotBeNull();

            File.WriteAllText(bicepFileName + ".formatted", formattedContents);

            originalContents.Should().EqualWithLineByLineDiffOutput(
                TestContext,
                formattedContents !,
                expectedLocation: example.BicepStreamName,
                actualLocation: bicepFileName + ".formatted");
        }
    private static bool ReadExcel()
    {
        ExcelPackage package = TableExcelLoader.Load("ExampleData");
        if (null == package)
        {
            return false;
        }
        ExcelWorksheet sheet = package.Workbook.Worksheets["ExampleData"];
        if (null == sheet)
        {
            return false;
        }
        int defaultKey = new int();
        for (int index = 1; index <= sheet.Dimension.Rows; ++index)
        {
            var tableData = new ExampleData();
            int innerIndex = 1;
            {
                tableData.ID = sheet.Cells[index, innerIndex++].GetValue<int>();
                tableData.Name = sheet.Cells[index, innerIndex++].GetValue<string>();
                tableData.FloatValue = sheet.Cells[index, innerIndex++].GetValue<float>();
                try
                {
                    tableData.EnumValue = (TestEnum)Enum.Parse(typeof(TestEnum), sheet.Cells[index, innerIndex++].GetValue<string>());
                }
                catch(System.Exception ex)
                {
                    Debug.LogException(ex);
                }
                int count_FixedList_4 = 5;
                tableData.FixedList = new int[count_FixedList_4];
                for (int index_FixedList_4 = 0; index_FixedList_4 < count_FixedList_4; ++index_FixedList_4)
                {
                    tableData.FixedList[index_FixedList_4] = sheet.Cells[index, innerIndex++].GetValue<int>();
                }
                int count_AutoList_4 = sheet.Cells[index, innerIndex++].GetValue<int>();
                tableData.AutoList = new int[count_AutoList_4];
                for (int index_AutoList_4 = 0; index_AutoList_4 < count_AutoList_4; ++index_AutoList_4)
                {
                    tableData.AutoList[index_AutoList_4] = sheet.Cells[index, innerIndex++].GetValue<int>();
                }
                ExampleInnerData obj_InnerData_4 = new ExampleInnerData();
                {
                    obj_InnerData_4.ID = sheet.Cells[index, innerIndex++].GetValue<int>();
                    int count_AutoList_5 = sheet.Cells[index, innerIndex++].GetValue<int>();
                    obj_InnerData_4.AutoList = new ExampleInnerInnerData[count_AutoList_5];
                    for (int index_AutoList_5 = 0; index_AutoList_5 < count_AutoList_5; ++index_AutoList_5)
                    {
                        obj_InnerData_4.AutoList[index_AutoList_5].ID = sheet.Cells[index, innerIndex++].GetValue<int>();
                        try
                        {
                            obj_InnerData_4.AutoList[index_AutoList_5].EnumValue = (TestEnum)Enum.Parse(typeof(TestEnum), sheet.Cells[index, innerIndex++].GetValue<string>());
                        }
                        catch(System.Exception ex)
                        {
                            Debug.LogException(ex);
                        }
                    }
                }
                tableData.InnerData = obj_InnerData_4;
                int count_InnerDataList_4 = sheet.Cells[index, innerIndex++].GetValue<int>();
                tableData.InnerDataList = new ExampleInnerData[count_InnerDataList_4];
                for (int index_InnerDataList_4 = 0; index_InnerDataList_4 < count_InnerDataList_4; ++index_InnerDataList_4)
                {
                    tableData.InnerDataList[index_InnerDataList_4].ID = sheet.Cells[index, innerIndex++].GetValue<int>();
                    int count_AutoList_5 = sheet.Cells[index, innerIndex++].GetValue<int>();
                    tableData.InnerDataList[index_InnerDataList_4].AutoList = new ExampleInnerInnerData[count_AutoList_5];
                    for (int index_AutoList_5 = 0; index_AutoList_5 < count_AutoList_5; ++index_AutoList_5)
                    {
                        tableData.InnerDataList[index_InnerDataList_4].AutoList[index_AutoList_5].ID = sheet.Cells[index, innerIndex++].GetValue<int>();
                        try
                        {
                            tableData.InnerDataList[index_InnerDataList_4].AutoList[index_AutoList_5].EnumValue = (TestEnum)Enum.Parse(typeof(TestEnum), sheet.Cells[index, innerIndex++].GetValue<string>());
                        }
                        catch(System.Exception ex)
                        {
                            Debug.LogException(ex);
                        }
                    }
                }
            }
            if (tableData.ID == defaultKey)
            {
                continue;
            }
            var existKey = m_data.Find(innerItem => innerItem.ID == tableData.ID);
            if (null != existKey)
            {
                Debug.LogWarning(string.Format("Already has the key {0}, replace the old data.", tableData.ID));
                m_data.Remove(existKey);
            }

            m_data.Add(tableData);
        }
        return true;
    }