public void DeleteProjectTest()
        {
            AccessService dbService = new AccessService();
            //var projectUpdates = dbService.GetProjectUpdates("6a8a7e56-e9ac-4385-a8be-5be702c1f2e6");
            UpdatePackage package = new UpdatePackage();

            package.ProjectName = "Test Project";
            package.Subject     = "Deployment";
            package.Body        = "Environment:br549|Jimmy, toloose";

            package.Updates.Add("verticalID", "3");
            package.Updates.Add("Environment", "br549");
            package.Updates.Add("Author", "Samantha");
            package.Updates.Add("Manager", "Bocephus");

            //__Adding this package should create a new Project and return the ProjectID as string
            string stId = dbService.RecordUpdatePackage(package);

            Assert.IsFalse(string.IsNullOrEmpty(stId));

            Guid projectID = Guid.Parse(stId);

            Assert.IsFalse(projectID == Guid.Empty);

            Guid recordedId = dbService.GetProjectIDbyName(package.ProjectName);

            Assert.AreEqual(projectID, recordedId);
            // This is the actual test - let's see if it actually deletes the project
            dbService.DeleteProject(projectID);

            // When we look for updates, it should be null or empty.
            // We will not test this part because the code crashes if you try and
            // delete a project that does not exist and we are in code freeze.
            // Assert.IsNull(dbService.GetAllUpdatesForProject(projectID.ToString()));
        }
        public void ChangeProjectUpdatePhaseTest1()
        {
            AccessService dbService = new AccessService();
            //var projectUpdates = dbService.GetProjectUpdates("6a8a7e56-e9ac-4385-a8be-5be702c1f2e6");
            UpdatePackage package = new UpdatePackage();

            package.ProjectName = "Test Getting Project Updates";
            package.Subject     = "Deployment";
            package.Body        = "Environment:br549|Jimmy, toloose";

            package.Updates.Add("verticalID", "3");
            package.Updates.Add("Environment", "br549");
            package.Updates.Add("Author", "Samantha");
            package.Updates.Add("Manager", "Bocephus");

            //__Adding this package should create a new Project and return the ProjectID as string
            string stId      = dbService.RecordUpdatePackage(package);
            Guid   projectID = Guid.Parse(stId);

            // Gotta convert this to a Project Update as opposed to a plain Update Project
            List <ProjectUpdate> pjUpdates = dbService.GetProjectUpdates(stId);

            pjUpdates[0].PhaseID = 4;
            pjUpdates[0].Phase   = "Build_and_Test"; // Don't think this needs to be done
            dbService.ChangeProjectUpdatePhase(pjUpdates[0]);
            List <ProjectUpdate> pjUpdateChanges = dbService.GetProjectUpdates(stId);

            Assert.IsTrue(pjUpdateChanges[0].PhaseID == 4);
            pjUpdateChanges[0].PhaseID = 5;
            dbService.ChangeProjectUpdatePhase(pjUpdateChanges[0]);
            List <ProjectUpdate> pjUpdateChangesMore = dbService.GetProjectUpdates(stId);

            Assert.IsTrue(pjUpdateChangesMore[0].PhaseID == 5);
            dbService.DeleteProject(projectID);
        }
Exemple #3
0
        public async Task Handle_RepublishRolledback_UpdateExisting()
        {
            var updatePackage = new UpdatePackage("1.0.0");

            updatePackage.AddDistribution("enduser");

            var distribution = updatePackage.Distributions.First();

            distribution.Rollback();

            var mockRepo = new Mock <IUpdatePackageRepository>();

            mockRepo.Setup(x => x.GetFirstOrDefaultBySpecs(It.IsAny <ISpecification <UpdatePackage>[]>())).ReturnsAsync(updatePackage);

            var useCase       = new PatchUpdatePackageUseCase(mockRepo.Object, GetSuccessfulAddFilesAction());
            var publishDate   = DateTimeOffset.UtcNow.AddHours(-1);
            var distributions = new List <UpdatePackageDistributionInfo> {
                new UpdatePackageDistributionInfo("enduser", publishDate)
            };
            var updatePackageInfo = new UpdatePackageInfo("1.0.0", null, null, new List <UpdateFileInfo>(), null, distributions);

            // act
            await useCase.Handle(new PatchUpdatePackageRequest(1, "1.0.0", updatePackageInfo, null));

            // assert
            Assert.False(useCase.HasError);

            Assert.Equal(distribution, Assert.Single(updatePackage.Distributions));

            Assert.True(distribution.IsDistributing);
            Assert.False(distribution.IsRolledBack);
            Assert.Equal(publishDate, distribution.PublishDate);
        }
Exemple #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            UpdatePackage newVersion = new UpdatePackage();

            newVersion.Version     = textBox1.Text;
            newVersion.PublishTime = dateTimePicker1.Value;
            newVersion.Title       = textBox2.Text;
            newVersion.Remark      = textBox3.Text;
            newVersion.FilesList   = dataGridView2.DataSource as List <UpdateFileModel>;
            string json = Util.Json.ToJson(newVersion);

            var path     = AppDomain.CurrentDomain.BaseDirectory;
            var filePath = path + VERSIONFILEINFO;

            try
            {
                File.WriteAllText(filePath, json, Encoding.UTF8);
            }
            catch (Exception ex)
            {
                MessageBox.Show("发布文件时发生错误:" + ex.Message);
            }
            MessageBox.Show("新版本发布成功");
            CurrentPackageInfo = newVersion;
            //VERSIONFILEINFO
        }
Exemple #5
0
        private async Task ExecutePackage(UpdatePackage package, CancellationToken?cancellationToken)
        {
            // Versioned Commands
            foreach (var command in EnumerableHelper.Enumerate(package.VersionedCommands))
            {
                if (IsCancelled(cancellationToken))
                {
                    // If cancelled, don't try the next version package, but do try and run the always run commands.
                    break;
                }

                try
                {
                    await ExecuteCommandAsync(command);
                }
                catch (Exception ex)
                {
                    await LogUpdateErrorAsync(package.ModuleIdentifier, command.Version, command.Description, ex);

                    throw;
                }

                await LogUpdateSuccessAsync(package.ModuleIdentifier, command.Version, command.Description);
            }

            // Always Run Commands
            foreach (var command in EnumerableHelper.Enumerate(package.AlwaysUpdateCommands))
            {
                await ExecuteCommandAsync(command);
            }
        }
        public void RecordUpdatePackageTest()
        {
            AccessService dbService = new AccessService();
            //var projectUpdates = dbService.GetProjectUpdates("6a8a7e56-e9ac-4385-a8be-5be702c1f2e6");
            UpdatePackage package = new UpdatePackage();

            package.ProjectName = "Test Project";
            package.Subject     = "Deployment";
            package.Body        = "Environment:br549|Jimmy, toloose";

            package.Updates.Add("verticalID", "3");
            package.Updates.Add("Environment", "br549");
            package.Updates.Add("Author", "Samantha");
            package.Updates.Add("Manager", "Bocephus");

            //__Adding this package should create a new Project and return the ProjectID as string
            string stId = dbService.RecordUpdatePackage(package);

            Assert.IsFalse(string.IsNullOrEmpty(stId));

            Guid projectID = Guid.Parse(stId);

            Assert.IsFalse(projectID == Guid.Empty);

            Guid recordedId = dbService.GetProjectIDbyName(package.ProjectName);

            Assert.AreEqual(projectID, recordedId);



            dbService.DeleteProject(projectID);
        }
        public void Setup()
        {
            if (OsInfo.IsLinux)
            {
                _updatePackage = new UpdatePackage
                {
                    FileName = "NzbDrone.develop.2.0.0.0.tar.gz",
                    Url      = "http://update.nzbdrone.com/v2/develop/mono/NzbDrone.develop.tar.gz",
                    Version  = new Version("2.0.0.0")
                };
            }

            else
            {
                _updatePackage = new UpdatePackage
                {
                    FileName = "NzbDrone.develop.2.0.0.0.zip",
                    Url      = "http://update.nzbdrone.com/v2/develop/windows/NzbDrone.develop.zip",
                    Version  = new Version("2.0.0.0")
                };
            }

            Mocker.GetMock <IAppFolderInfo>().SetupGet(c => c.TempFolder).Returns(TempFolder);
            Mocker.GetMock <ICheckUpdateService>().Setup(c => c.AvailableUpdate()).Returns(_updatePackage);
            Mocker.GetMock <IVerifyUpdates>().Setup(c => c.Verify(It.IsAny <UpdatePackage>(), It.IsAny <String>())).Returns(true);

            Mocker.GetMock <IProcessProvider>().Setup(c => c.GetCurrentProcess()).Returns(new ProcessInfo {
                Id = 12
            });
            Mocker.GetMock <IRuntimeInfo>().Setup(c => c.ExecutingApplication).Returns(@"C:\Test\NzbDrone.exe");

            _sandboxFolder = Mocker.GetMock <IAppFolderInfo>().Object.GetUpdateSandboxFolder();
        }
Exemple #8
0
        public async Task Handle_RenameFile_NoSigningRequired()
        {
            var updatePackage = new UpdatePackage("1.0.0");

            updatePackage.AddFile(new UpdateFile("wrong_path.txt", "ff", "NICE SIGNATURE"));

            var mockRepo = new Mock <IUpdatePackageRepository>();

            mockRepo.Setup(x => x.GetFirstOrDefaultBySpecs(It.IsAny <ISpecification <UpdatePackage>[]>())).ReturnsAsync(updatePackage);

            var useCase           = new PatchUpdatePackageUseCase(mockRepo.Object, GetSuccessfulAddFilesAction());
            var files             = new[] { new UpdateFileInfo("right_path.txt", Hash.Parse("FF")) };
            var updatePackageInfo = new UpdatePackageInfo("1.0.0", null, null, files.ToList(), null, null);

            // act
            await useCase.Handle(new PatchUpdatePackageRequest(1, "1.0.0", updatePackageInfo, null));

            // assert
            Assert.False(useCase.HasError);

            var file = Assert.Single(updatePackage.Files);

            Assert.Equal("right_path.txt", file.Path);
            Assert.Equal("ff", file.Hash);
            Assert.Equal("NICE SIGNATURE", file.Signature);
        }
Exemple #9
0
        public async Task Handle_GivenSameCustomFields_DontUpdateProperty()
        {
            var customFields = new Dictionary <string, string> {
                { "hello", "world" }
            };
            var customFieldsValue = customFields.ToImmutableDictionary();
            var updatePackage     = new UpdatePackage("1.0.0")
            {
                CustomFields = customFieldsValue
            };

            var mockRepo = new Mock <IUpdatePackageRepository>();

            mockRepo.Setup(x => x.GetFirstOrDefaultBySpecs(It.IsAny <ISpecification <UpdatePackage>[]>())).ReturnsAsync(updatePackage);

            var useCase           = new PatchUpdatePackageUseCase(mockRepo.Object, GetSuccessfulAddFilesAction());
            var updatePackageInfo = new UpdatePackageInfo("1.0.0", null, customFields, new List <UpdateFileInfo>(), null, null);

            // act
            await useCase.Handle(new PatchUpdatePackageRequest(1, "1.0.0", updatePackageInfo, null));

            // assert
            Assert.False(useCase.HasError);

            Assert.Equal(customFieldsValue, updatePackage.CustomFields);
        }
Exemple #10
0
        public async Task Handle_GivenChangedChangelog_UpdateExisting()
        {
            var updatePackage = new UpdatePackage("1.0.0");

            updatePackage.AddChangelog("de-de", "Hallo Wlt");
            updatePackage.AddChangelog("fr-fr", "Bonjour l'monde");

            var changelog = updatePackage.Changelogs.First();

            var mockRepo = new Mock <IUpdatePackageRepository>();

            mockRepo.Setup(x => x.GetFirstOrDefaultBySpecs(It.IsAny <ISpecification <UpdatePackage>[]>())).ReturnsAsync(updatePackage);

            var useCase = new PatchUpdatePackageUseCase(mockRepo.Object, GetSuccessfulAddFilesAction());
            var newChangelogs = new[] { new UpdateChangelogInfo("de-de", "Hallo Welt"), new UpdateChangelogInfo("en-us", "Hello World") }.ToList();
            var updatePackageInfo = new UpdatePackageInfo("1.0.0", null, null, new List <UpdateFileInfo>(), newChangelogs, null);

            // act
            await useCase.Handle(new PatchUpdatePackageRequest(1, "1.0.0", updatePackageInfo, null));

            // assert
            Assert.False(useCase.HasError);

            Assert.Collection(updatePackage.Changelogs, x =>
            {
                Assert.Equal("de-de", x.Language);
                Assert.Equal("Hallo Welt", x.Content);
                Assert.Equal(changelog, x); // reference equal
            },
                              x =>
            {
                Assert.Equal("en-us", x.Language);
                Assert.Equal("Hello World", x.Content);
            });
        }
        public async Task Handle_PrivateKeyPlainOnServer_ShouldSucceed()
        {
            var mockProjectRepo = new Mock <IProjectRepository>();

            mockProjectRepo.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new Project("test", new AsymmetricKey("PUBLIC KEY", "PLAIN KEY")));

            var mockFilesRepo = new Mock <IStoredFileRepository>();

            mockFilesRepo.Setup(x => x.FindByHash(It.IsAny <Hash>())).ReturnsAsync(new StoredFile("HASH", 100, 80));

            var mockAsymCrypto = new Mock <IAsymmetricCryptoHandler>();

            mockAsymCrypto.Setup(x => x.SignHash(It.IsAny <Hash>(), "PLAIN KEY")).Returns("FILE SIGNATURE");

            var action = new AddUpdatePackageFilesAction(mockFilesRepo.Object, mockProjectRepo.Object, mockAsymCrypto.Object, null);

            var files = new List <UpdateFileInfo>
            {
                new UpdateFileInfo("asd", Hash.Parse("FF")),
                new UpdateFileInfo("asd2", Hash.Parse("EE")),
            };

            var package = new UpdatePackage("1.0.0");

            // act
            await action.AddFiles(package, files, null);

            // assert
            Assert.False(action.HasError);

            Assert.Equal(2, package.Files.Count());
            Assert.Collection(package.Files, x => Assert.Equal("FILE SIGNATURE", x.Signature), x => Assert.Equal("FILE SIGNATURE", x.Signature));
        }
        public async Task Handle_GivenFilesWithInvalidSignature_PrivateKeyNotOnServer_ShouldFail()
        {
            var mockProjectRepo = new Mock <IProjectRepository>();

            mockProjectRepo.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new Project("test", new AsymmetricKey("PUBLIC KEY")));

            var mockFilesRepo = new Mock <IStoredFileRepository>();

            mockFilesRepo.Setup(x => x.FindByHash(It.IsAny <Hash>())).ReturnsAsync(new StoredFile("HASH", 100, 80));

            var mockAsymCrypto = new Mock <IAsymmetricCryptoHandler>();

            mockAsymCrypto.Setup(x => x.VerifyHash(It.IsAny <Hash>(), "SIGNATURE", "PUBLIC KEY")).Returns(false);

            var action = new AddUpdatePackageFilesAction(mockFilesRepo.Object, mockProjectRepo.Object, mockAsymCrypto.Object, null);

            var files = new List <UpdateFileInfo>
            {
                new UpdateFileInfo("asd", Hash.Parse("FF"), "SIGNATURE")
            };

            var package = new UpdatePackage("1.0.0");

            // act
            await action.AddFiles(package, files, null);

            // assert
            ErrorUtils.AssertError(action, ErrorType.ValidationError);
        }
Exemple #13
0
        void WriteFiles()
        {
            var writing = Stopwatch.StartNew();

            var dataUpdate = new UpdatePackage("data");
            var jsout = new JsOutput(dataUpdate);
            jsout.Write();

            // Has to be after everything else because partials are modified here.
            var searchUpdate = new UpdatePackage("search");
            var sqlout = new SearchOutput(jsout, searchUpdate);
            sqlout.Write();

            if (dataUpdate.RowCount > 0)
            {
                DatabaseBuilder.PrintLine($"Updating {dataUpdate.RowCount} data rows.");
                dataUpdate.Write();
            }

            if (searchUpdate.RowCount > 0)
            {
                DatabaseBuilder.PrintLine($"Updating {searchUpdate.RowCount} data rows.");
                searchUpdate.Write();
            }

            writing.Stop();
            DatabaseBuilder.PrintLine($"Writing elapsed: {writing.Elapsed}");
        }
        public async Task Handle_GivenInvalidKeyPassword_PrivateKeyEncryptedOnServer_ShouldFail()
        {
            var mockProjectRepo = new Mock <IProjectRepository>();

            mockProjectRepo.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(new Project("test", new AsymmetricKey("PUBLIC KEY", "ENCRYPTED KEY", true)));

            var mockFilesRepo = new Mock <IStoredFileRepository>();

            mockFilesRepo.Setup(x => x.FindByHash(It.IsAny <Hash>())).ReturnsAsync(new StoredFile("HASH", 100, 80));

            var mockSymmCrypto = new Mock <ISymmetricEncryption>();

            mockSymmCrypto.Setup(x => x.DecryptString("ENCRYPTED KEY", "Invalid Password")).Throws(new Exception("Invalid Password"));

            var action = new AddUpdatePackageFilesAction(mockFilesRepo.Object, mockProjectRepo.Object, null, mockSymmCrypto.Object);

            var files = new List <UpdateFileInfo>
            {
                new UpdateFileInfo("asd", Hash.Parse("FF"), "")
            };

            var package = new UpdatePackage("1.0.0");

            // act
            await action.AddFiles(package, files, "Invalid Password");

            // assert
            ErrorUtils.AssertError(action, ErrorType.ValidationError);
        }
Exemple #15
0
        public void Setup()
        {
            if (OsInfo.IsLinux)
            {
                _updatePackage = new UpdatePackage
                {
                    FileName = "NzbDrone.develop.2.0.0.0.tar.gz",
                    Url      = "http://update.nzbdrone.com/v2/develop/mono/NzbDrone.develop.tar.gz",
                    Version  = new Version("2.0.0.0")
                };
            }

            else
            {
                _updatePackage = new UpdatePackage
                {
                    FileName = "NzbDrone.develop.2.0.0.0.zip",
                    Url      = "http://update.nzbdrone.com/v2/develop/windows/NzbDrone.develop.zip",
                    Version  = new Version("2.0.0.0")
                };
            }

            Mocker.GetMock <IAppFolderInfo>().SetupGet(c => c.TempFolder).Returns(TempFolder);
            Mocker.GetMock <ICheckUpdateService>().Setup(c => c.AvailableUpdate()).Returns(_updatePackage);

            Mocker.GetMock <IProcessProvider>().Setup(c => c.GetCurrentProcess()).Returns(new ProcessInfo {
                Id = 12
            });

            _sandboxFolder = Mocker.GetMock <IAppFolderInfo>().Object.GetUpdateSandboxFolder();
        }
Exemple #16
0
        /// <summary>
        /// Adds the pages to update package.
        /// </summary>
        /// <param name="package">The package.</param>
        /// <param name="applicationRoot">The application root.</param>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="pages">The pages.</param>
        /// <param name="depth">The depth.</param>
        private static void AddPagesToUpdatePackage(UpdatePackage package, string applicationRoot, RockContext rockContext, IEnumerable <PageCache> pages, int depth = 0)
        {
            foreach (var page in pages)
            {
                var additionalPageSettings = page.AdditionalSettings.FromJsonOrNull <AdditionalPageSettings>() ?? new AdditionalPageSettings();

                var mobilePage = new MobilePage
                {
                    LayoutGuid         = page.Layout.Guid,
                    DisplayInNav       = page.DisplayInNavWhen == DisplayInNavWhen.WhenAllowed,
                    Title              = page.PageTitle,
                    PageGuid           = page.Guid,
                    Order              = page.Order,
                    ParentPageGuid     = page.ParentPage?.Guid,
                    IconUrl            = page.IconBinaryFileId.HasValue ? $"{ applicationRoot }GetImage.ashx?Id={ page.IconBinaryFileId.Value }" : null,
                    LavaEventHandler   = additionalPageSettings.LavaEventHandler,
                    DepthLevel         = depth,
                    AuthorizationRules = string.Join(",", GetOrderedExplicitAuthorizationRules(page))
                };

                package.Pages.Add(mobilePage);

                var childPages = page.GetPages(rockContext);
                if (childPages.Any())
                {
                    AddPagesToUpdatePackage(package, applicationRoot, rockContext, childPages, depth + 1);
                }
            }
        }
Exemple #17
0
        public async Task Handle_NewFiles_SigningRequired()
        {
            var updatePackage = new UpdatePackage("1.0.0");

            updatePackage.AddFile(new UpdateFile("wrong_path.txt", "ff", "NICE SIGNATURE"));

            var mockRepo = new Mock <IUpdatePackageRepository>();

            mockRepo.Setup(x => x.GetFirstOrDefaultBySpecs(It.IsAny <ISpecification <UpdatePackage>[]>())).ReturnsAsync(updatePackage);

            var mockAddFiles = new Mock <IAddUpdatePackageFilesAction>();

            mockAddFiles.Setup(x => x.AddFiles(It.IsAny <UpdatePackage>(), It.IsAny <IEnumerable <UpdateFileInfo> >(), It.IsAny <string>()))
            .Returns(Task.CompletedTask);
            mockAddFiles.SetupGet(x => x.HasError).Returns(false);

            var useCase           = new PatchUpdatePackageUseCase(mockRepo.Object, mockAddFiles.Object);
            var files             = new[] { new UpdateFileInfo("path2.txt", Hash.Parse("AA")) };
            var updatePackageInfo = new UpdatePackageInfo("1.0.0", null, null, files.ToList(), null, null);

            // act
            await useCase.Handle(new PatchUpdatePackageRequest(1, "1.0.0", updatePackageInfo, null));

            // assert
            Assert.False(useCase.HasError);

            mockAddFiles.Verify(x => x.AddFiles(It.IsAny <UpdatePackage>(), It.IsAny <IEnumerable <UpdateFileInfo> >(), It.IsAny <string>()), Times.Once);
        }
Exemple #18
0
 public ClientBaseForm()
 {
     CurrentPackageInfo = new UpdatePackage();
     CurrentConfig      = new ConfigEntity();
     //SocketClientInit();
     //LoadVersionInfo();  todo:版本检测
     //AudioChatClient = new AudioChatClient(CurrentConfig);
 }
        private IEnumerable <UpdatePackage> FindDependencies(UpdatePackage packageToGetDependenciesFor, Dictionary <string, IEnumerable <UpdatePackage> > dependentModuleLookup)
        {
            var dependencies = EnumerableHelper
                               .Enumerate(packageToGetDependenciesFor.DependentModules)
                               .SelectMany(moduleCode => dependentModuleLookup.GetOrDefault(moduleCode, Enumerable.Empty <UpdatePackage>()));

            return(dependencies);
        }
        public UpdatePackage GetUpdatePackage()
        {
            UpdatePackage updatePackage = new UpdatePackage();

            updatePackage.ProjectName = ProjectName;
            updatePackage.Subject     = Subject;
            updatePackage.Body        = Body;
            updatePackage.Updates     = Updates;
            return(updatePackage);
        }
 protected static IEnumerable <StockRow> GetRows(UpdatePackage package)
 {
     return(package.Stocks.Select(s => new StockRow
     {
         ProductCode = s.ProductCode,
         Stock = s.Stock,
         StoreNo = package.StoreNo,
         Timestamp = package.Timestamp
     }).OrderBy(r => r.Timestamp));
 }
        private static UpdatePackage CreateUpdatePackage(SemVersion version, int?orderNumber = null)
        {
            var package = new UpdatePackage(version);

            if (orderNumber != null)
            {
                package.OrderNumber = orderNumber.Value;
            }

            return(package);
        }
 private void CopyDistributions(UpdatePackage package, IEnumerable <UpdatePackageDistributionInfo> distributions)
 {
     foreach (var distributionDto in distributions)
     {
         var distribution = package.AddDistribution(distributionDto.Name);
         if (distributionDto.PublishDate != null)
         {
             distribution.Publish(distributionDto.PublishDate);
         }
     }
 }
Exemple #24
0
        public void Constructor1_OneInput()
        {
            UpdatePackage test = new UpdatePackage(new Vector2(1, 1), new Vector2(1, 1));

            Vector2[] actual = new Vector2[2] {
                test.position, test.velocity
            };
            Vector2[] expected = new Vector2[2] {
                new Vector2(1, 1), new Vector2(1, 1)
            };
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #25
0
        public void Constructor1_ZeroInput()
        {
            UpdatePackage test = new UpdatePackage(new Vector2(0, 0), new Vector2(0, 0));

            Vector2[] actual = new Vector2[2] {
                test.position, test.velocity
            };
            Vector2[] expected = new Vector2[2] {
                Vector2.Zero, Vector2.Zero
            };
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #26
0
        public void Constructor0_MinInput()
        {
            UpdatePackage test = new UpdatePackage(new Vector2(float.MinValue, float.MinValue));

            Vector2[] actual = new Vector2[2] {
                test.position, test.velocity
            };
            Vector2[] expected = new Vector2[2] {
                new Vector2(float.MinValue, float.MinValue), Vector2.Zero
            };
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #27
0
        public void InfoUpdate1_MaxInput()
        {
            UpdatePackage test = new UpdatePackage(Vector2.Zero);

            test.InfoUpdate(new Vector2(float.MaxValue, float.MaxValue), new Vector2(float.MaxValue, float.MaxValue));
            Vector2[] actual = new Vector2[2] {
                test.position, test.velocity
            };
            Vector2[] expected = new Vector2[2] {
                new Vector2(float.MaxValue, float.MaxValue), new Vector2(float.MaxValue, float.MaxValue)
            };
            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #28
0
        public void InfoUpdate1_MinusOneInput()
        {
            UpdatePackage test = new UpdatePackage(Vector2.Zero);

            test.InfoUpdate(new Vector2(-1, -1), new Vector2(-1, -1));
            Vector2[] actual = new Vector2[2] {
                test.position, test.velocity
            };
            Vector2[] expected = new Vector2[2] {
                new Vector2(-1, -1), new Vector2(-1, -1)
            };
            CollectionAssert.AreEqual(expected, actual);
        }
        protected override async Task Persist(UpdatePackage package)
        {
            await using var transaction = await this._context.Database.BeginTransactionAsync();

            // can't be enumerable because the lib needs to know the total count for batching
            var rows = GetRows(package).ToList();

            await this._context.BulkInsertAsync(rows);

            await this._context.SaveChangesAsync();

            await transaction.CommitAsync();
        }
        protected override async Task Persist(UpdatePackage package)
        {
            await using var transaction = await this._context.Database.BeginTransactionAsync();

            foreach (var stockRow in GetRows(package))
            {
                await this._context.Stocks.AddAsync(stockRow);
            }

            await this._context.SaveChangesAsync();

            await transaction.CommitAsync();
        }