var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "@web-atoms/unit-test/dist/Assert", "@web-atoms/unit-test/dist/Test", "../../di/DISingleton", "../../di/Inject", "../../unit/AtomTest"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Assert_1 = require("@web-atoms/unit-test/dist/Assert");
    var Test_1 = require("@web-atoms/unit-test/dist/Test");
    var DISingleton_1 = require("../../di/DISingleton");
    var Inject_1 = require("../../di/Inject");
    var AtomTest_1 = require("../../unit/AtomTest");
    var InjectTest = /** @class */ (function (_super) {
        __extends(InjectTest, _super);
        function InjectTest() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        InjectTest.prototype.propertyInjection = function () {
            var vm = this.app.resolve(VM, true);
            var first = vm.propertyService.time;
            var vm2 = this.app.resolve(VM, true);
            var second = vm2.propertyService.time;
            Assert_1.default.equals(first, second);
        };
        InjectTest.prototype.propertyInjectionWithConstructor = function () {
            var vm = this.app.resolve(VM2, true);
            var first = vm.propertyService.time;
            var vm2 = this.app.resolve(VM2, true);
            var second = vm2.propertyService.time;
            Assert_1.default.equals(first, second);
        };
        InjectTest.prototype.inheritedPropertyTest = function () {
            var bvm = this.app.resolve(BaseVM, true);
            var bvm2 = this.app.resolve(BaseVM, true);
            var bf = bvm.service.time;
            var bf2 = bvm.service.time;
            Assert_1.default.equals(bf, bf2);
            // child
            var cvm = this.app.resolve(ChildVM, true);
            var cvm2 = this.app.resolve(ChildVM, true);
            var cf = cvm.service.time;
            var cf2 = cvm2.service.time;
            Assert_1.default.equals(cf, cf2);
            var cs = cvm.propertyService.time;
            var cs2 = cvm2.propertyService.time;
            Assert_1.default.equals(cs, cs2);
        };
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], InjectTest.prototype, "propertyInjection", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], InjectTest.prototype, "propertyInjectionWithConstructor", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], InjectTest.prototype, "inheritedPropertyTest", null);
        return InjectTest;
    }(AtomTest_1.AtomTest));
    exports.default = InjectTest;
    var Service = /** @class */ (function () {
        function Service() {
            this.time = (new Date()).getTime();
        }
        Service = __decorate([
            DISingleton_1.default(),
            __metadata("design:paramtypes", [])
        ], Service);
        return Service;
    }());
    var PropertyService = /** @class */ (function () {
        function PropertyService() {
            this.time = (new Date()).getTime();
        }
        PropertyService = __decorate([
            DISingleton_1.default(),
            __metadata("design:paramtypes", [])
        ], PropertyService);
        return PropertyService;
    }());
    var VM = /** @class */ (function () {
        function VM() {
        }
        __decorate([
            Inject_1.Inject,
            __metadata("design:type", PropertyService)
        ], VM.prototype, "propertyService", void 0);
        return VM;
    }());
    var VM2 = /** @class */ (function () {
        function VM2(service) {
            this.service = service;
        }
        __decorate([
            Inject_1.Inject,
            __metadata("design:type", PropertyService)
        ], VM2.prototype, "propertyService", void 0);
        VM2 = __decorate([
            __param(0, Inject_1.Inject),
            __metadata("design:paramtypes", [Service])
        ], VM2);
        return VM2;
    }());
    var BaseVM = /** @class */ (function () {
        function BaseVM() {
        }
        __decorate([
            Inject_1.Inject,
            __metadata("design:type", Service)
        ], BaseVM.prototype, "service", void 0);
        return BaseVM;
    }());
    var ChildVM = /** @class */ (function (_super) {
        __extends(ChildVM, _super);
        function ChildVM() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            Inject_1.Inject,
            __metadata("design:type", PropertyService)
        ], ChildVM.prototype, "propertyService", void 0);
        return ChildVM;
    }(BaseVM));
});
//# sourceMappingURL=InjectTest.js.map