From 95d1452eefadffaf1ec75dd0a8336bc2c387eb17 Mon Sep 17 00:00:00 2001
From: gcontini <1121667+gcontini@users.noreply.github.com>
Date: 周六, 01 2月 2020 02:48:51 +0800
Subject: [PATCH] rename enums and further developments

---
 test/functional/date_test.cpp |   49 +++++++++++++++++++++++++++----------------------
 1 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/test/functional/date_test.cpp b/test/functional/date_test.cpp
index c15ab4e..999331c 100644
--- a/test/functional/date_test.cpp
+++ b/test/functional/date_test.cpp
@@ -1,11 +1,12 @@
-#define BOOST_TEST_MODULE date_test
-//#define BOOST_TEST_MAIN
-//#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE test_date
+
 #include <boost/test/unit_test.hpp>
-#include "../../../src/tools/license-generator/license-generator.h"
-#include "../../../src/library/api/license++.h"
-#include <build_properties.h>
 #include <boost/filesystem.hpp>
+
+#include <licensecc_properties.h>
+#include <licensecc_properties_test.h>
+
+#include <licensecc/licensecc.h>
 #include "../../src/library/ini/SimpleIni.h"
 #include "generate-license.h"
 
@@ -13,38 +14,42 @@
 using namespace license;
 using namespace std;
 
-BOOST_AUTO_TEST_CASE( license_not_expired ) {
-	const string licLocation(PROJECT_TEST_TEMP_DIR "/not_expired.lic");
+namespace license {
+namespace test {
+
+BOOST_AUTO_TEST_CASE(license_not_expired) {
 	vector<string> extraArgs;
 	extraArgs.push_back("-e");
 	extraArgs.push_back("2050-10-10");
-	generate_license(licLocation, extraArgs);
+	const string licLocation = generate_license("not_expired.lic", extraArgs);
 	/* */
 	LicenseInfo license;
-	LicenseLocation licenseLocation;
-	licenseLocation.openFileNearModule = false;
-	licenseLocation.licenseFileLocation = licLocation.c_str();
-	licenseLocation.environmentVariableName = "";
-	EVENT_TYPE result = acquire_license("TEST", licenseLocation, &license);
+	LicenseLocation location = {LICENSE_PATH};
+	std::copy(licLocation.begin(), licLocation.end(), location.licenseData);
+
+	const LCC_EVENT_TYPE result = acquire_license(nullptr, &location, &license);
 	BOOST_CHECK_EQUAL(result, LICENSE_OK);
 	BOOST_CHECK_EQUAL(license.has_expiry, true);
 	BOOST_CHECK_EQUAL(license.linked_to_pc, false);
+	BOOST_CHECK_GT(license.days_left, 0);
 }
 
-BOOST_AUTO_TEST_CASE( license_expired ) {
-	const string licLocation(PROJECT_TEST_TEMP_DIR "/expired.lic");
+BOOST_AUTO_TEST_CASE(license_expired) {
 	vector<string> extraArgs;
 	extraArgs.push_back("-e");
 	extraArgs.push_back("2013-10-10");
-	generate_license(licLocation, extraArgs);
+	const string licLocation = generate_license("expired", extraArgs);
 	/* */
 	LicenseInfo license;
-	LicenseLocation licenseLocation;
-	licenseLocation.openFileNearModule = false;
-	licenseLocation.licenseFileLocation = licLocation.c_str();
-	licenseLocation.environmentVariableName = "";
-	EVENT_TYPE result = acquire_license("TEST", licenseLocation, &license);
+	LicenseLocation location = {LICENSE_PATH};
+	std::copy(licLocation.begin(), licLocation.end(), location.licenseData);
+	BOOST_TEST_MESSAGE("before acquire license");
+	const LCC_EVENT_TYPE result = acquire_license(nullptr, &location, &license);
 	BOOST_CHECK_EQUAL(result, PRODUCT_EXPIRED);
 	BOOST_CHECK_EQUAL(license.has_expiry, true);
 	BOOST_CHECK_EQUAL(license.linked_to_pc, false);
+	BOOST_CHECK_EQUAL(license.days_left, 0);
 }
+
+}  // namespace test
+}  // namespace license

--
Gitblit v1.9.1