コード例 #1
0
        public void CreateBoundary_DuplicateNameNotValid()
        {
            const string boundaryName = "Boundary Web test 1";

            this.Msg.Title(boundaryName, "Create boundary with duplicate name");

            var boundaryRequest = BoundaryRequest.Create(string.Empty, boundaryName, boundaryWKT);
            var boundary        = JsonConvert.SerializeObject(boundaryRequest, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });
            var responseCreate   = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}", "PUT", boundary);
            var boundaryResponse = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseCreate, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });

            Assert.AreEqual("success", boundaryResponse.Message, "Expecting success");
            //Now duplicate
            responseCreate   = ts.CallFilterWebApi($"api/v1/boundary/{ProjectUid}", "PUT", boundary);
            boundaryResponse = JsonConvert.DeserializeObject <GeofenceDataSingleResult>(responseCreate, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });
            Assert.AreEqual("Duplicate boundary name", boundaryResponse.Message, "Expecting duplicate boundary name");
            Assert.AreEqual(2062, boundaryResponse.Code, "Wrong error code");
        }
コード例 #2
0
        public void CreateSimpleFilter(FilterType filterType)
        {
            ts.DeleteAllFiltersForProject(ProjectUid.ToString());

            const string filterName = "Filter Web test 1";

            Msg.Title(filterName, $"Create {filterType } filter with all the defaults in the filter json");

            var filterJson = CreateTestFilter();

            var filterRequest = FilterRequest.Create(string.Empty, filterName, filterJson, filterType);
            var filter        = JsonConvert.SerializeObject(filterRequest, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });
            var responseCreate = ts.CallFilterWebApi($"api/v1/filter/{ProjectUid}", "PUT", filter);
            var filterResponse = JsonConvert.DeserializeObject <FilterDescriptorSingleResult>(responseCreate, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });

            Assert.AreEqual(filterResponse.FilterDescriptor.FilterJson, filterJson, "JSON Filter doesn't match for PUT request");
            Assert.AreEqual(filterResponse.FilterDescriptor.Name, filterName, "Filter name doesn't match for PUT request");
            Assert.AreEqual(filterResponse.FilterDescriptor.FilterType, filterType, "Filter type doesn't match for PUT request");
            var filterUid         = filterResponse.FilterDescriptor.FilterUid;
            var responseGet       = ts.CallFilterWebApi($"api/v1/filter/{ProjectUid}?filterUid={filterUid}", "GET");
            var filterResponseGet = JsonConvert.DeserializeObject <FilterDescriptorSingleResult>(responseGet, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });

            Assert.AreEqual(filterResponseGet.FilterDescriptor.FilterJson, filterJson, "JSON Filter doesn't match for GET request");
            Assert.AreEqual(filterResponseGet.FilterDescriptor.Name, filterName, "Filter name doesn't match for GET request");
            Assert.AreEqual(filterResponseGet.FilterDescriptor.FilterType, filterType, "Filter type doesn't match for GET request");
        }
コード例 #3
0
        public void InsertFilterInDatabaseAndGetItFromWebApi(FilterType filterType)
        {
            const string filterName = "Filter DbWeb test 1";

            Msg.Title(filterName, "Insert Filter In Database And Get It From WebApi");
            var filterUid = Guid.NewGuid();

            ts.CustomerUid = CustomerUid;
            var filterJson  = CreateTestFilter();
            var eventsArray = new[] {
                "| TableName | FilterUID   | fk_CustomerUID | fk_ProjectUID | UserID   | Name         | fk_FilterTypeID   | FilterJson    | IsDeleted | LastActionedUTC |",
                $"| Filter    | {filterUid} | {CustomerUid}  | {ProjectUid}  | {UserId} | {filterName} | {(int)filterType} | {filterJson}  | 0         | {ts.EventDate:yyyy-MM-dd} |"
            };

            ts.PublishEventCollection(eventsArray);
            mysql.VerifyTestResultDatabaseRecordCount("Filter", "FilterUID", 1, filterUid);
            var responseGet       = ts.CallFilterWebApi($"api/v1/filter/{ProjectUid}?filterUid={filterUid}", "GET");
            var filterResponseGet = JsonConvert.DeserializeObject <FilterDescriptorSingleResult>(responseGet, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });

            Assert.AreEqual(filterResponseGet.FilterDescriptor.FilterJson, filterJson, "JSON Filter doesn't match for GET request");
            Assert.AreEqual(filterResponseGet.FilterDescriptor.Name, filterName, "Filter name doesn't match for GET request");
            Assert.AreEqual(filterResponseGet.FilterDescriptor.FilterType, filterType, "Filter type doesn't match for GET request");
        }