it("should verify BuildService.GetBuildDefinitions", async function() {
        this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts

        const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl);
        ctx.CredentialHandler = CredentialManager.GetCredentialHandler();
        ctx.RepoInfo = Mocks.RepositoryInfo();
        ctx.UserInfo = undefined;

        const svc: BuildService = new BuildService(ctx);
        const definitions = await svc.GetBuildDefinitions(TestSettings.TeamProject);
        assert.isNotNull(definitions, "definitions was null when it shouldn't have been");
        //console.log(definitions.length);
        expect(definitions.length).to.be.at.least(1);
    });
    it("should verify WorkItemTrackingService.CreateWorkItem", async function() {
        this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts

        const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl);
        ctx.CredentialHandler = CredentialManager.GetCredentialHandler();
        ctx.RepoInfo = Mocks.RepositoryInfo();
        ctx.UserInfo = undefined;

        const itemType : string = "Bug";
        const today: Date = new Date();
        const title: string = "Work item created by integration test (" + today.toLocaleString() + ")";
        const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx);
        const item: WorkItem = await svc.CreateWorkItem(ctx, itemType, title);
        assert.isNotNull(item, "item was null when it shouldn't have been");
    });
    it("should verify WorkItemTrackingService.GetWorkItemQuery", async function() {
        this.timeout(TestSettings.TestTimeout); //http://mochajs.org/#timeouts

        const ctx: TeamServerContext = Mocks.TeamServerContext(TestSettings.RemoteRepositoryUrl);
        ctx.CredentialHandler = CredentialManager.GetCredentialHandler();
        ctx.RepoInfo = Mocks.RepositoryInfo();
        ctx.UserInfo = undefined;

        const svc: WorkItemTrackingService = new WorkItemTrackingService(ctx);
        const query: QueryHierarchyItem = await svc.GetWorkItemQuery(TestSettings.TeamProject, TestSettings.WorkItemQueryPath);
        assert.isNotNull(query);
        //console.log(query);
        expect(query.id).to.equal(TestSettings.WorkItemQueryId);
        const items: SimpleWorkItem[] = await svc.GetWorkItems(TestSettings.TeamProject, query.wiql);
        assert.isTrue(items.length > 0);
    });
Пример #4
0
 it('works with Map<X,Object>', () => {
     let map = new Map<string, Thing>();
     map.set('1', new Thing(1, '1'));
     let storePath = path.join(process.cwd(), 'x.db');
     encoder.serializeToFileSync(storePath, map);
     let other = encoder.deserializeFromFileSync(storePath);
     let found: Thing = null;
     for (let thing of map.values()) {
         if (thing.xname == '1') {
             found = thing;
             break;;
         }
     }
     let type = typeof found;
     assert.isTrue('object' == type)
     assert.isNotNull(found);
     //WRONG they are both MAPs not Objects 
     assert.deepEqual(map, other);
 })
        it("gives the correct regression equation, R^2, and function for a sample input with strong correlation", ()=>{
            const data:[number,number][] = [
                [0,0.33517481],
                [1,3.00712561],
                [2,6.73118302],
                [3,9.25128682],
                [4,12.0432596],
                [5,15.9087018],
                [6,18.71122156],
                [7,21.69213527],
                [8,24.57708193],
                [9,27.98002031],
                [10,30.67017471],
                [11,33.55231386],
                [12,36.20724938],
                [13,39.21414698],
                [14,42.74163248],
                [15,45.95986539],
                [16,48.28399276],
                [17,51.52361803],
                [18,54.62495359]
            ];

            const computations = getRegressionComputations(data);
            // target values computed via python: scipy.stats.linregress
            const m = 3.0120636256561446;
            const b = 0.41853989070105158;
            const r2 = 0.99970735279778178;
            // test regression equation to make sure its approximately the same as what python gives
            const match = computations.string.match(/y = ([\d.]+)x \+ ([\d.]+)/);
            assert.isNotNull(match, "equation has correct form");
            const M = parseFloat(match![1]);
            const B = parseFloat(match![2]);
            assert.approximately(M, m, 0.05);
            assert.approximately(B, b, 0.05);
            // make sure `predict` gives the same result as the equation
            for (let i=0; i<100; i+=1) {
                assert.approximately(computations.predict(i)[1], M*i + B, 0.0000005, `value for ${i}`);
            }
            // test R^2
            assert.approximately(computations.r2,  r2, 0.05, "R^2");
        });
Пример #6
0
	it('should return appropriate step constraint', () => {
		const api = createApi();
		const obj = {foo: 1};
		const bapi = api.addInput(obj, 'foo', {
			step: 1,
		});

		const iv = bapi.controller.controller.value;
		assert.instanceOf(iv, InputValue);

		if (!(iv instanceof InputValue)) {
			throw new Error('Input value is empty');
		}
		const c: Constraint<unknown> | null = TypeUtil.forceCast(iv.constraint);
		if (!c) {
			throw new Error('Constraint is empty');
		}

		assert.isNotNull(ConstraintUtil.findConstraint(c, StepConstraint));
	});
Пример #7
0
    it('should return error for invalid specs', function() {
      assert.isNotNull(getEncodingMappingError({
        mark: LINE,
        encoding: {
          x: {field: 'b'} // missing y
        }
      }));

      assert.isNotNull(getEncodingMappingError({
        mark: AREA,
        encoding: {
          y: {field: 'b'} // missing x
        }
      }));

      assert.isNotNull(getEncodingMappingError({
        mark: TEXT,
        encoding: {
          y: {field: 'b'} // missing text
        }
      }));

      assert.isNotNull(getEncodingMappingError({
        mark: LINE,
        encoding: {
          shape: {field: 'b'} // using shape with line
        }
      }));

      assert.isNotNull(getEncodingMappingError({
        mark: AREA,
        encoding: {
          shape: {field: 'b'} // using shape with area
        }
      }));

      assert.isNotNull(getEncodingMappingError({
        mark: BAR,
        encoding: {
          shape: {field: 'b'} // using shape with bar
        }
      }));
    });
Пример #8
0
 todo.save<AV.Object>().then((todo)=>{
   // 保存成功,可以打开控制台核对修改结果
   chai.assert.isNotNull(todo.get('title'));
   done();
 },(error)=>{
Пример #9
0
 execCli(["-c", "./test/config/tslint-custom-rules.json", "-r", "./someRandomDir", "src/test.ts"], (err) => {
     assert.isNotNull(err, "process should exit with error");
     assert.strictEqual(err.code, 1, "error code should be 1");
     done();
 });
 .then((work: Work) => {
   assert.isNotNull(work.result);
   assert.equal(work.result.result, 3);
   assert.lengthOf(work.childrenIDs, 1);
   assert.lengthOf(work.finishedChildrenIDs, 1);
 });