Esempio n. 1
0
        public IActionResult Create()
        {
            var testdata = new Testdata {
                CreateDate = DateTime.Now
            };

            return(View(testdata));
        }
Esempio n. 2
0
        public void TestDataInstance()
        {
            Testdata testdata = new Testdata();

            Assert.Equal(42, testdata.Value);
            Assert.Equal("Data", testdata.Name);
            Assert.Equal("00000000-0000-0000-0000-000000000000", testdata.Uuid.ToString());
            Assert.Equal("0.0.0.0", testdata.Address);
            Assert.Equal("0.0.0.0:80", testdata.Endpoint);
            Assert.Equal("http://127.0.0.1:80", testdata.Uri);
            Assert.Equal("OK", testdata.Code.ToString());
        }
Esempio n. 3
0
        public void CheckCRUDCreate()
        {
            // Arrange
            CRUDController controller = new CRUDController(_mockRepo.Object, _logger, _hubContext.Object);
            // Act
            Testdata testdata = new Testdata()
            {
                Title = "Teszt cím", Value = "Teszt érték"
            };
            var result = controller.Create(0, testdata);

            // Assert
            Assert.NotNull(result);
        }
Esempio n. 4
0
        public IActionResult Edit(int Id, [Bind("Id, Title, Value, CreateDate")] Testdata testdata)
        {
            if (!ModelState.IsValid)
            {
                return(View(testdata));
            }
            _repo.UpdateTestdata(testdata);

            SignalRDispatcher dispatcher = new SignalRDispatcher(_hubContext);
            SignalRMessage    srm        = new SignalRMessage($"{DateTime.Now}", "Update", testdata.Title, testdata.Value);

            dispatcher.SendToAllClient(srm.Serialize());

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 5
0
        public IActionResult DeleteConfirmed(int id)
        {
            if (!ModelState.IsValid)
            {
                return(View(id));
            }
            Testdata testdata = _repo.RemoveTestdata(id);

            SignalRDispatcher dispatcher = new SignalRDispatcher(_hubContext);
            SignalRMessage    srm        = new SignalRMessage($"{DateTime.Now}", "Remove", testdata.Title, testdata.Value);

            dispatcher.SendToAllClient(srm.Serialize());

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 6
0
        public BasicTestData()
        {
            var services      = new ServiceCollection();
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json")
                                .AddJsonFile("testdata.json").Build();

            services.AddSingleton(configuration.GetSection("AppSettings").Get <AppSettings>().ValidateAndThrow());
            services.AddSingleton(configuration.GetSection("TestData").Get <Testdata>().ValidateAndThrow());
            var provider = services.BuildServiceProvider();

            _settings = provider.GetService <AppSettings>();
            _testdata = provider.GetService <Testdata>();
        }
Esempio n. 7
0
        static void Main()
        {
            var testdata = new Testdata();

            Console.WriteLine(testdata.Konto5021);
            Console.WriteLine(testdata.SchablonKostnad);



            testdata.ResultatAvdelning();
            testdata.ResultatProduktX();
            testdata.ResultatProduktY();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmLoggaIn());
        }
        public void Create_ModelStateValid_CreateEmployeeCalledOnce()
        {
            Testdata testdata = null;

            _mockRepo.Setup(r => r.CreateTestdata(It.IsAny <Testdata>()))
            .Callback <Testdata>(x => testdata = x);

            testdata = new Testdata {
                Title = "qqq",
                Value = "aaa"
            };

            _controller.Create(0, testdata);

            _mockRepo.Verify(x => x.CreateTestdata(It.IsAny <Testdata>()), Times.Once);

            Assert.Equal(testdata.Title, testdata.Title);
            Assert.Equal(testdata.Value, testdata.Value);
        }
 public void UpdateTestdata(Testdata testdata)
 {
     _context.Update(testdata);
     _context.SaveChanges();
 }
Esempio n. 10
0
 public void CreateTestdata(Testdata testdata)
 {
     _context.Add(testdata);
     _context.SaveChanges();
 }
Esempio n. 11
0
        /// <summary>
        ///  Initializes a new instance of the <see cref="TestdataCommand"/> class.
        ///  Note that the code option is hidden in the help output (see https://github.com/dotnet/command-line-api/issues/629).
        /// </summary>
        /// <param name="testdata"></param>
        /// <param name="logger"></param>
        public TestdataCommand(Testdata testdata,
                               ILogger <TestdataCommand> logger)
            : base("testdata", "A dotnet console application sub command - testdata command")
        {
            logger.LogDebug("TestCommand()");

            // Setup command options.
            AddOption(new Option <bool>          (new string[] { "-j", "--json" }, "show json output"));
            AddOption(new Option <bool>          (new string[] { "-n", "--new" }, "show new data"));
            AddOption(new Option <Guid>          (new string[] { "-g", "--guid" }, "specify GUID"));
            AddOption(new Option <string>        (new string[] { "-a", "--address" }, "specify IP address").IPAddress());
            AddOption(new Option <string>        (new string[] { "-e", "--endpoint" }, "specify IP endpoint").IPEndpoint());
            AddOption(new Option <string>        (new string[] { "-u", "--uri" }, "specify absolute URI").Uri());
            AddOption(new Option <HttpStatusCode>(new string[] { "-c", "--code" }, "specify HTTP status code").Hide());

            // Setup execution handler.
            Handler = CommandHandler.Create <IConsole, bool, TestdataOptions>((console, verbose, options) =>
            {
                logger.LogInformation("Handler()");

                if (verbose)
                {
                    console.Out.WriteLine($"Commandline Application: {RootCommand.ExecutableName}");
                    console.Out.WriteLine($"Console Log level: {CommandLineHost.ConsoleSwitch.MinimumLevel}");
                    console.Out.WriteLine($"File Log level: {CommandLineHost.FileSwitch.MinimumLevel}");
                    console.Out.WriteLine();
                }

                if (options.NewData)
                {
                    var data = new Testdata();

                    console.Out.WriteLine($"TestData():");
                    console.Out.WriteLine($"    Value:    {data.Value}");
                    console.Out.WriteLine($"    Name:     {data.Name}");
                    console.Out.WriteLine($"    Uuid:     {data.Uuid}");
                    console.Out.WriteLine($"    Address:  {data.Address}");
                    console.Out.WriteLine($"    Endpoint: {data.Endpoint}");
                    console.Out.WriteLine($"    Uri:      {data.Uri}");
                    console.Out.WriteLine($"    Code:     {data.Code}");

                    console.Out.WriteLine();
                }

                if (options.Json)
                {
                    console.Out.WriteLine($"TestData: {JsonSerializer.Serialize(testdata, _jsonoptions)}");
                    console.Out.WriteLine();
                }

                console.Out.WriteLine($"TestData:");
                console.Out.WriteLine($"    Value:    {testdata.Value}");
                console.Out.WriteLine($"    Name:     {testdata.Name}");
                console.Out.WriteLine($"    Uuid:     {testdata.Uuid}");
                console.Out.WriteLine($"    Address:  {testdata.Address}");
                console.Out.WriteLine($"    Endpoint: {testdata.Endpoint}");
                console.Out.WriteLine($"    Uri:      {testdata.Uri}");
                console.Out.WriteLine($"    Code:     {testdata.Code}");

                console.Out.WriteLine();

                console.Out.WriteLine($"CommandLine:");

                if (options.Guid.HasValue)
                {
                    console.Out.WriteLine($"    Guid:     {options.Guid}");
                }
                if (!(options.Address is null))
                {
                    console.Out.WriteLine($"    Address:  {options.Address}");
                }
                if (!(options.Endpoint is null))
                {
                    console.Out.WriteLine($"    Endpoint: {options.Endpoint}");
                }
                if (!(options.Uri is null))
                {
                    console.Out.WriteLine($"    Uri:      {options.Uri}");
                }
                if (!(options.Code is null))
                {
                    console.Out.WriteLine($"    Code:     {options.Code}");
                }

                console.Out.WriteLine();

                return(ExitCodes.SuccessfullyCompleted);
            });
        }